mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-02-24 01:32:22 +01:00
52 lines
813 B
PHP
52 lines
813 B
PHP
<?php
|
|
|
|
namespace DesignPatterns\Structural\Proxy;
|
|
|
|
/**
|
|
* class Record.
|
|
*/
|
|
class Record
|
|
{
|
|
/**
|
|
* @var array|null
|
|
*/
|
|
protected $data;
|
|
|
|
/**
|
|
* @param null $data
|
|
*/
|
|
public function __construct($data = null)
|
|
{
|
|
$this->data = (array) $data;
|
|
}
|
|
|
|
/**
|
|
* magic setter.
|
|
*
|
|
* @param string $name
|
|
* @param mixed $value
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __set($name, $value)
|
|
{
|
|
$this->data[(string) $name] = $value;
|
|
}
|
|
|
|
/**
|
|
* magic getter.
|
|
*
|
|
* @param string $name
|
|
*
|
|
* @return mixed|null
|
|
*/
|
|
public function __get($name)
|
|
{
|
|
if (array_key_exists($name, $this->data)) {
|
|
return $this->data[(string) $name];
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
}
|