diff --git a/Structural/Proxy/Record.php b/Structural/Proxy/Record.php index fd9bb0c..ea018b2 100644 --- a/Structural/Proxy/Record.php +++ b/Structural/Proxy/Record.php @@ -3,7 +3,7 @@ namespace DesignPatterns\Structural\Proxy; /** - * class Record. + * @property string username */ class Record { @@ -21,31 +21,20 @@ class Record } /** - * magic setter - * * @param string $name - * @param mixed $value - * - * @return void + * @param string $value */ public function __set(string $name, string $value) { $this->data[$name] = $value; } - /** - * magic getter - * - * @param string $name - * - * @return string|null - */ public function __get(string $name): string { - if (isset($this->data[$name])) { - return $this->data[$name]; - } else { - return null; + if (!isset($this->data[$name])) { + throw new \OutOfRangeException('Invalid name given'); } + + return $this->data[$name]; } } diff --git a/Structural/Proxy/RecordProxy.php b/Structural/Proxy/RecordProxy.php index 2432e01..4d29ee8 100644 --- a/Structural/Proxy/RecordProxy.php +++ b/Structural/Proxy/RecordProxy.php @@ -32,8 +32,6 @@ class RecordProxy extends Record } /** - * magic setter - * * @param string $name * @param string $value */ @@ -44,9 +42,6 @@ class RecordProxy extends Record parent::__set($name, $value); } - /** - * @return bool - */ public function isDirty(): bool { return $this->isDirty; diff --git a/Structural/Proxy/Tests/ProxyTest.php b/Structural/Proxy/Tests/ProxyTest.php index 955282f..efdf3f3 100644 --- a/Structural/Proxy/Tests/ProxyTest.php +++ b/Structural/Proxy/Tests/ProxyTest.php @@ -10,7 +10,7 @@ class ProxyTest extends \PHPUnit_Framework_TestCase public function testWillSetDirtyFlagInProxy() { $recordProxy = new RecordProxy([]); - $recordProxy->foobar = 'baz'; + $recordProxy->username = 'baz'; $this->assertTrue($recordProxy->isDirty()); } @@ -18,7 +18,7 @@ class ProxyTest extends \PHPUnit_Framework_TestCase public function testProxyIsInstanceOfRecord() { $recordProxy = new RecordProxy([]); - $recordProxy->foobar = 'baz'; + $recordProxy->username = 'baz'; $this->assertInstanceOf('DesignPatterns\Structural\Proxy\Record', $recordProxy); }