1 | <?php |
||
40 | abstract class Locker implements \Countable { |
||
41 | |||
42 | /** |
||
43 | * Holds the locked identifier associated to the keys. |
||
44 | * @var array |
||
45 | */ |
||
46 | protected $locked; |
||
47 | |||
48 | 1 | public function __construct() { |
|
51 | |||
52 | /** |
||
53 | * Locks the identifier and returns an unlock key. |
||
54 | * Extended by the Registry class, override and unregister methods of the |
||
55 | * Registry class are disabled for this identifier(s) |
||
56 | * @param string $identifier the identifier to lock |
||
57 | * @throws \Brickoo\Component\Common\Exception\LockFailedException |
||
58 | * @return string the unlock key |
||
59 | */ |
||
60 | 3 | public function lock($identifier) { |
|
70 | |||
71 | /** |
||
72 | * Unlocks the locked identifier matching the lock key. |
||
73 | * @param string $identifier the identifier which should be unlocked |
||
74 | * @param string $unlockKey the key to unlock the identifier |
||
75 | * @throws \Brickoo\Component\Common\Exception\UnlockFailedException |
||
76 | * @return \Brickoo\Component\Common\Locker |
||
77 | */ |
||
78 | 4 | public function unlock($identifier, $unlockKey) { |
|
89 | |||
90 | /** |
||
91 | * Checks if the identifier is currently locked. |
||
92 | * @param string $identifier the identifier to check |
||
93 | * @return boolean check result |
||
94 | */ |
||
95 | 2 | public function isLocked($identifier) { |
|
99 | |||
100 | /** |
||
101 | * Countable interface function. |
||
102 | * Returns the number of locked identifiers. |
||
103 | * @see Countable::count() |
||
104 | * @return integer the number of locked identifiers |
||
105 | */ |
||
106 | 1 | public function count() { |
|
109 | |||
110 | /** |
||
111 | * Abstract method needed to check if the identifier is available. |
||
112 | * @param string $identifier the identifier to check |
||
113 | * @return boolean check result |
||
114 | */ |
||
115 | abstract public function isIdentifierAvailable($identifier); |
||
116 | |||
117 | } |
||
118 |