Conditions | 5 |
Paths | 8 |
Total Lines | 31 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 30 |
Changes | 0 |
1 | <?php |
||
23 | public static function tryHandle(&$data, $parent, $parentField) |
||
24 | { |
||
25 | $className = ''; |
||
26 | $handled = false; |
||
27 | if(!empty($parent)) |
||
28 | { |
||
29 | $event = new UnknownDocumentType(); |
||
30 | $event->setData($data); |
||
31 | $event->parent = $parent; |
||
32 | $event->field = $parentField; |
||
33 | |||
34 | $handled = Event::handled($parent, UnknownDocumentType::EventName, $event); |
||
35 | if($handled) |
||
36 | { |
||
37 | $data = $event->getData(); |
||
38 | if(empty($data['_class'])) |
||
39 | { |
||
40 | $handled = false; |
||
41 | } |
||
42 | else |
||
43 | { |
||
44 | $className = $data['_class']; |
||
45 | } |
||
46 | } |
||
47 | } |
||
48 | if(!$handled) |
||
|
|||
49 | { |
||
50 | throw new TransformatorException('Could not determine document type'); |
||
51 | } |
||
52 | return $className; |
||
53 | } |
||
54 | } |
If an expression can have both
false
, andnull
as possible values. It is generally a good practice to always use strict comparison to clearly distinguish between those two values.