1: | <?php |
2: | |
3: | namespace Teto\Object; |
4: | |
5: | use function sprintf; |
6: | |
7: | /** |
8: | * Restrict write to not accessable property. |
9: | * |
10: | * @see \Teto\Object\PrivateGetterTest |
11: | * |
12: | * @author USAMI Kenta <tadsan@zonu.me> |
13: | * @copyright 2016 Baguette HQ |
14: | * @license http://www.apache.org/licenses/LICENSE-2.0 |
15: | */ |
16: | trait ReadOnlyTrait |
17: | { |
18: | public function __set($name, $_value) |
19: | { |
20: | $message = sprintf('%s->%s is not writable property.', static::class, $name); |
21: | throw new \OutOfRangeException($message); |
22: | } |
23: | } |
24: |