Conditions | 3 |
Paths | 3 |
Total Lines | 13 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | 3 | public function executeActions(ActionInterface $action) |
|
16 | { |
||
17 | 3 | if (property_exists($this, 'container')) { |
|
18 | 1 | return $this->container->get('thruster_actions.executor')->execute($action); |
|
|
|||
19 | 2 | } elseif (method_exists($this, 'getContainer')) { |
|
20 | 1 | return $this->getContainer()->get('thruster_actions.executor')->execute($action); |
|
21 | } |
||
22 | |||
23 | 1 | throw new \LogicException( |
|
24 | 'ActionsAwareTrait require Symfony Container accessible via property' . |
||
25 | 1 | '$container or ->getContainer() method' |
|
26 | ); |
||
27 | } |
||
28 | } |
||
29 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: