PHP Classes

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: Update of examples/onBefore/bandwidth.php
Date: 8 months 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);