| Total Complexity | 7 |
| Total Lines | 49 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | class Defence |
||
| 13 | { |
||
| 14 | /** @var SimpleFilterChain */ |
||
| 15 | private $filterChain; |
||
| 16 | |||
| 17 | /** @var HandlerInterface */ |
||
| 18 | private $handler; |
||
| 19 | |||
| 20 | 6 | public function __construct(SimpleFilterChain $filterChain, HandlerInterface $handler) |
|
| 21 | { |
||
| 22 | 6 | $this |
|
| 23 | 6 | ->setFilterChain($filterChain) |
|
| 24 | 6 | ->setHandler($handler) |
|
| 25 | 6 | ; |
|
| 26 | } |
||
| 27 | |||
| 28 | 6 | private function setFilterChain(SimpleFilterChain $filterChain): self |
|
| 29 | { |
||
| 30 | 6 | $this->filterChain = $filterChain; |
|
| 31 | |||
| 32 | 6 | return $this; |
|
| 33 | } |
||
| 34 | |||
| 35 | 6 | public function getFilterChain(): SimpleFilterChain |
|
| 36 | { |
||
| 37 | 6 | return $this->filterChain; |
|
| 38 | } |
||
| 39 | |||
| 40 | 6 | private function setHandler(HandlerInterface $handler): self |
|
| 41 | { |
||
| 42 | 6 | $this->handler = $handler; |
|
| 43 | |||
| 44 | 6 | return $this; |
|
| 45 | } |
||
| 46 | |||
| 47 | 5 | public function getHandler(): HandlerInterface |
|
| 48 | { |
||
| 49 | 5 | return $this->handler; |
|
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Executes the filter chain and, if the request was deemed suspicious, triggers the handler. |
||
| 54 | */ |
||
| 55 | 3 | public function execute(Envelope $envelope): void |
|
| 61 | } |
||
| 62 | } |
||
| 63 | } |
||
| 64 |