-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLockableContainer.php
57 lines (49 loc) · 1.21 KB
/
LockableContainer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* Created by PhpStorm.
* User: Eric
* Date: 11/5/2014
* Time: 11:12 PM
*
* Allows for information to be locked once it is entered
*/
namespace Facade;
abstract class LockableContainer extends Container
{
private $locked = false;
public function lock()
{
$this->locked = true;
}
protected function handle_set($name,$value)
{
if($this->locked) throw new \Exception('Cannot set item once Lockable Container is Locked');
else return true;
}
protected function handle_get($name)
{
return true;
}
protected function alter_get($name)
{
throw new \Exception("cannot get '$name', not field in object");
}
protected function handle_isset($name)
{
return true;
}
protected function handle_unset($name)
{
return false;
}
protected function alter_set($name,$value)
{
$trace = debug_backtrace();
trigger_error(
'Undefined property via __set(): ' . $name .
' in ' . $trace[0]['file'] .
' on line ' . $trace[0]['line'],
E_USER_NOTICE);
throw new \Exception("Property '$name' not defined in LockableContainer");
}
}