PHP code example of clippings / freezable
1. Go to this page and download the library: Download clippings/freezable library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
clippings / freezable example snippets
php
use Clippings\Freezable\FreezableTrait;
class Item {
use FreezableTrait;
private $value = NULL;
public function performFreeze()
{
$this->value = $this->computeValue();
}
public function performUnfreeze()
{
$this->value = NULL;
}
private function computeValue()
{
// computation from external sources, database, other objects etc.
return pi() * pi();
}
public function getValue()
{
return $this->isFrozen() ? $this->value : $this->computeValue();
}
}