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