File: examples/onBefore/bandwidth.php

Recommend this page to a friend!
  Classes of Nicola Covolo  >  Decorate  >  examples/onBefore/bandwidth.php  >  Download  
File: examples/onBefore/bandwidth.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Decorate
Alter functions running code before and after
Author: By
Last change:
Date: 6 years ago
Size: 443 bytes
 

Contents

Class file image Download
<?php

require "../../Decorate.php";

$bandwidth = function ($position)
{
   
$position->x = min($position->x, 50);
   
$position->y = min($position->y, 50);
   
$position->z = min($position->z, 50);
}
;

$saveToDB = function ($position)
{
   
//doquery etc..
   
print_r($position);
}
;

$saveToDB = Decorate::onBefore($saveToDB, $bandwidth);

$position = (object)array(
   
'x' => 100,
   
'y' => 100,
   
'z' => 100);
$saveToDB($position);


For more information send a message to info at phpclasses dot org.