| Conditions | 4 |
| Paths | 3 |
| Total Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 18 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | 9 | public function __invoke(EntityContainer $container, $ann) |
|
| 18 | { |
||
| 19 | 9 | $ref = new \ReflectionClass($container->getClassName()); |
|
| 20 | 9 | $container->getClassName(); |
|
|
|
|||
| 21 | 9 | $properties = $ref->getProperties(\ReflectionProperty::IS_PUBLIC); |
|
| 22 | 9 | $default = $ref->getDefaultProperties(); |
|
| 23 | 9 | $container->setFileName($ref->getFileName()); |
|
| 24 | |||
| 25 | 9 | $container->setDescription($ann->description); |
|
| 26 | 9 | $container->setSummary($ann->summary); |
|
| 27 | |||
| 28 | 9 | foreach ($properties as $i){ |
|
| 29 | 9 | $isOption = array_key_exists($i->getName(), $default) && $default[$i->getName()] !==null; |
|
| 30 | 9 | $container->setProperty($i->getName(), new PropertyMeta( |
|
| 31 | 9 | $i->getName(), |
|
| 32 | 9 | null, |
|
| 33 | 9 | $isOption, |
|
| 34 | 9 | $isOption?$default[$i->getName()]:null |
|
| 35 | 9 | )); |
|
| 36 | 9 | } |
|
| 37 | } |
||
| 38 | } |
PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.
Let’s take a look at an example:
If we look at the
getEmail()method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:On the hand, if we look at the
setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call: