mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-30 11:40:13 +02:00
41 lines
690 B
PHP
41 lines
690 B
PHP
<?php
|
|
|
|
namespace DesignPatterns\Structural\Proxy;
|
|
|
|
/**
|
|
* @property string username
|
|
*/
|
|
class Record
|
|
{
|
|
/**
|
|
* @var string[]
|
|
*/
|
|
private $data;
|
|
|
|
/**
|
|
* @param string[] $data
|
|
*/
|
|
public function __construct(array $data = [])
|
|
{
|
|
$this->data = $data;
|
|
}
|
|
|
|
/**
|
|
* @param string $name
|
|
* @param string $value
|
|
*/
|
|
public function __set(string $name, string $value)
|
|
{
|
|
$this->data[$name] = $value;
|
|
}
|
|
|
|
public function __get(string $name): string
|
|
{
|
|
if (!isset($this->data[$name])) {
|
|
throw new \OutOfRangeException('Invalid name given');
|
|
}
|
|
|
|
return $this->data[$name];
|
|
}
|
|
}
|