Conditions | 7 |
Paths | 7 |
Total Lines | 24 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 56 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
35 | public function encode($type, $value) |
||
36 | { |
||
37 | if (!$this->isPrimitive($type)) { |
||
38 | if ($value instanceof Contracts\Entity) { |
||
39 | return $value->getId(); |
||
40 | } |
||
41 | |||
42 | return +$value; |
||
43 | } |
||
44 | |||
45 | if ($type == 'integer') { |
||
46 | return $value ? +$value : 0; |
||
47 | } |
||
48 | |||
49 | if (is_null($value)) { |
||
50 | return; |
||
51 | } |
||
52 | |||
53 | if (!is_array($value)) { |
||
54 | return "$value"; |
||
55 | } |
||
56 | |||
57 | return $value; |
||
58 | } |
||
59 | |||
78 |