| Conditions | 15 | 
| Paths | 15 | 
| Total Lines | 59 | 
| Code Lines | 29 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php  | 
            ||
| 17 | public function encodeValue(int $type, $value = null): ?string  | 
            ||
| 18 |     { | 
            ||
| 19 |         if ($type === Binn::BINN_NULL) { | 
            ||
| 20 | return '';  | 
            ||
| 21 | }  | 
            ||
| 22 | |||
| 23 |         if ($type === Binn::BINN_TRUE) { | 
            ||
| 24 | return '';  | 
            ||
| 25 | }  | 
            ||
| 26 | |||
| 27 |         if ($type === Binn::BINN_FALSE) { | 
            ||
| 28 | return '';  | 
            ||
| 29 | }  | 
            ||
| 30 | |||
| 31 |         if ($type === Binn::BINN_UINT64) { | 
            ||
| 32 | return Packer::packUint64($value);  | 
            ||
| 33 | }  | 
            ||
| 34 | |||
| 35 |         if ($type === Binn::BINN_UINT32) { | 
            ||
| 36 | return Packer::packUint32($value);  | 
            ||
| 37 | }  | 
            ||
| 38 | |||
| 39 |         if ($type === Binn::BINN_UINT16) { | 
            ||
| 40 | return Packer::packUint16($value);  | 
            ||
| 41 | }  | 
            ||
| 42 | |||
| 43 |         if ($type === Binn::BINN_UINT8) { | 
            ||
| 44 | return Packer::packUint8($value);  | 
            ||
| 45 | }  | 
            ||
| 46 | |||
| 47 |         if ($type === Binn::BINN_INT8) { | 
            ||
| 48 | return Packer::packInt8($value);  | 
            ||
| 49 | }  | 
            ||
| 50 | |||
| 51 |         if ($type === Binn::BINN_INT16) { | 
            ||
| 52 | return Packer::packInt16($value);  | 
            ||
| 53 | }  | 
            ||
| 54 | |||
| 55 |         if ($type === Binn::BINN_INT32) { | 
            ||
| 56 | return Packer::packInt32($value);  | 
            ||
| 57 | }  | 
            ||
| 58 | |||
| 59 |         if ($type === Binn::BINN_INT64) { | 
            ||
| 60 | return Packer::packInt64($value);  | 
            ||
| 61 | }  | 
            ||
| 62 | |||
| 63 |         if ($type === Binn::BINN_FLOAT32) { | 
            ||
| 64 | return Packer::packFloat32($value);  | 
            ||
| 65 | }  | 
            ||
| 66 | |||
| 67 |         if ($type === Binn::BINN_FLOAT64) { | 
            ||
| 68 | return Packer::packFloat64($value);  | 
            ||
| 69 | }  | 
            ||
| 70 | |||
| 71 |         if ($type === Binn::BINN_STRING) { | 
            ||
| 72 | return Packer::packSize(strlen($value)) . Packer::packString($value) . "\x00";  | 
            ||
| 73 | }  | 
            ||
| 74 | |||
| 75 | return null;  | 
            ||
| 76 | }  | 
            ||
| 152 |