Completed
Pull Request — master (#42)
by Frederik
02:56
created

AbstractCommand   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 18
c 0
b 0
f 0
ccs 0
cts 7
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
createStream() 0 1 ?
A toStream() 0 7 1
1
<?php
2
3
namespace Genkgo\Mail\Protocol\Imap\Request;
4
5
use Genkgo\Mail\Protocol\Imap\RequestInterface;
6
use Genkgo\Mail\Stream\ConcatenatedStream;
7
use Genkgo\Mail\Stream\StringStream;
8
use Genkgo\Mail\StreamInterface;
9
10
/**
11
 * Class AbstractCommand
12
 * @package Genkgo\Mail\Protocol\Imap\Request
13
 */
14
abstract class AbstractCommand implements RequestInterface
15
{
16
    /**
17
     * @return StreamInterface
18
     */
19
    abstract protected function createStream(): StreamInterface;
20
21
    /**
22
     * @return StreamInterface
23
     */
24
    final public function toStream(): StreamInterface
25
    {
26
        return new ConcatenatedStream([
0 ignored issues
show
Documentation introduced by
array(new \Genkgo\Mail\S... $this->createStream()) is of type array<integer,object<Gen...il\\StreamInterface>"}>, but the function expects a object<Genkgo\Mail\Stream\iterable>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
27
            new StringStream((string)$this->getTag() . ' '),
28
            $this->createStream()
29
        ]);
30
    }
31
}
32