1 | <?php |
||
10 | class Flaps |
||
11 | { |
||
12 | /** |
||
13 | * @var StorageInterface |
||
14 | */ |
||
15 | protected $adapter; |
||
16 | |||
17 | public function __construct(StorageInterface $adapter) |
||
21 | /** |
||
22 | * @var ViolationHandlerInterface |
||
23 | */ |
||
24 | protected $defaultViolationHandler = null; |
||
25 | |||
26 | /** |
||
27 | * Sets a default violation handler for flaps created in the future. |
||
28 | * @param \BehEh\Flaps\ViolationHandlerInterface $violationHandler |
||
29 | */ |
||
30 | 1 | public function setDefaultViolationHandler(ViolationHandlerInterface $violationHandler) |
|
34 | |||
35 | /** |
||
36 | * Creates a new Flap and returns it, setting default violation handler., |
||
37 | * @param string $name the name of the flap |
||
38 | * @return \BehEh\Flaps\Flap the created flap |
||
39 | */ |
||
40 | 1 | public function getFlap($name) |
|
41 | { |
||
42 | 1 | $flap = new Flap($this->adapter, $name); |
|
43 | 1 | if ($this->defaultViolationHandler !== null) { |
|
44 | 1 | $flap->setViolationHandler($this->defaultViolationHandler); |
|
45 | } |
||
46 | 1 | return $flap; |
|
47 | } |
||
48 | |||
49 | /** |
||
50 | * Creates a new Flap and returns it, setting default violation handler., |
||
51 | * @param string $name the name of the flap |
||
52 | * @return \BehEh\Flaps\Flap |
||
53 | * @see BehEh\Flaps\Flaps::getFlap |
||
54 | */ |
||
55 | 1 | public function __get($name) |
|
59 | } |
||
60 |