BinnEncode   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
c 1
b 0
f 0
dl 0
loc 20
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A encode() 0 10 3
A __construct() 0 3 1
1
<?php
2
3
namespace Knik\Binn\Encoder;
4
5
use Knik\Binn\Contracts\BinnValueEncoder;
6
7
class BinnEncode
8
{
9
    /** @var EncoderCollection */
10
    private $encoders;
11
12
    public function __construct(EncoderCollection $encoders)
13
    {
14
        $this->encoders = $encoders;
15
    }
16
17
    public function encode($value, $format, $context = []): ?string
0 ignored issues
show
Unused Code introduced by
The parameter $format is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

17
    public function encode($value, /** @scrutinizer ignore-unused */ $format, $context = []): ?string

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $context is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

17
    public function encode($value, $format, /** @scrutinizer ignore-unused */ $context = []): ?string

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
18
    {
19
        /** @var BinnValueEncoder $encoder */
20
        foreach ($this->encoders->getAll() as $encoder) {
21
            if ($encoder->supportsEncoding($value)) {
22
                return $encoder->encode($value);
23
            }
24
        }
25
26
        return "\x00";
27
    }
28
}
29