Conditions | 7 |
Paths | 7 |
Total Lines | 24 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 7 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
46 | 64 | public function encode($type, $value) |
|
47 | { |
||
48 | 64 | if (!$this->isPrimitive($type)) { |
|
49 | 5 | if ($value instanceof Contracts\Entity) { |
|
50 | 5 | return $value->getId(); |
|
51 | } |
||
52 | |||
53 | 5 | return +$value; |
|
54 | } |
||
55 | |||
56 | 64 | if ($type == 'integer') { |
|
57 | 64 | return $value ? +$value : 0; |
|
58 | } |
||
59 | |||
60 | 64 | if (is_null($value)) { |
|
61 | 1 | return; |
|
62 | } |
||
63 | |||
64 | 64 | if (!is_array($value)) { |
|
65 | 64 | return "$value"; |
|
66 | } |
||
67 | |||
68 | 3 | return $value; |
|
69 | } |
||
70 | |||
89 |