| Conditions | 1 |
| Paths | 1 |
| Total Lines | 30 |
| Code Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 29 | public function __construct( |
||
| 30 | Type $type, |
||
| 31 | Channel $channel, |
||
| 32 | Method $method, |
||
| 33 | Value ...$values |
||
| 34 | ) { |
||
| 35 | $this->type = $type; |
||
| 36 | $this->channel = $channel; |
||
| 37 | $this->method = $method; |
||
| 38 | $values = new Sequence(...$values); |
||
| 39 | $payload = $values->join('')->toEncoding('ASCII'); |
||
| 40 | $frame = new Sequence( |
||
| 41 | new UnsignedOctet($type->toInt()), |
||
|
|
|||
| 42 | new UnsignedShortInteger($channel->toInt()), |
||
| 43 | new UnsignedLongInteger( |
||
| 44 | $payload->length() + 4 // 4 is the size for the method |
||
| 45 | ), |
||
| 46 | new UnsignedShortInteger($method->class()), |
||
| 47 | new UnsignedShortInteger($method->method()), |
||
| 48 | $payload, |
||
| 49 | new UnsignedOctet(0xCE) |
||
| 50 | ); |
||
| 51 | $this->values = $values->reduce( |
||
| 52 | new Stream(Value::class), |
||
| 53 | static function(Stream $stream, Value $value): Stream { |
||
| 54 | return $stream->add($value); |
||
|
1 ignored issue
–
show
|
|||
| 55 | } |
||
| 56 | ); |
||
| 57 | $this->string = (string) $frame->join(''); |
||
| 58 | } |
||
| 59 | |||
| 88 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: