1 | <?php |
||
17 | final class Ssr implements RenderInterface |
||
18 | { |
||
19 | /** |
||
20 | * @var BaracoaInterface |
||
21 | */ |
||
22 | private $baracoa; |
||
23 | |||
24 | /** |
||
25 | * @var string |
||
26 | */ |
||
27 | private $appName; |
||
28 | |||
29 | /** |
||
30 | * @var array |
||
31 | */ |
||
32 | private $stateKeys; |
||
33 | |||
34 | /** |
||
35 | * @var array |
||
36 | */ |
||
37 | private $metaKeys; |
||
38 | |||
39 | /** |
||
40 | * @param BaracoaInterface $baracoa |
||
41 | */ |
||
42 | 4 | public function __construct(BaracoaInterface $baracoa, string $appName, array $stateKeys = [], array $metasKeys = []) |
|
49 | |||
50 | 4 | public function render(ResourceObject $ro) |
|
51 | { |
||
52 | 4 | $state = $this->filter($this->stateKeys, (array) $ro->body, StatusKeyNotExistsException::class); |
|
53 | 3 | $metas = $this->filter($this->metaKeys, (array) $ro->body, MetaKeyNotExistsException::class); |
|
54 | 2 | $html = $this->baracoa->render($this->appName, $state, $metas); |
|
55 | 1 | $ro->view = $html; |
|
56 | |||
57 | 1 | return $html; |
|
58 | } |
||
59 | |||
60 | 4 | private function filter(array $keys, array $body, string $exception) : array |
|
75 | } |
||
76 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.