Passed
Push — master ( a626ba...b864c0 )
by Zaahid
15:44 queued 12:03
created

GenericHeader::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 14
ccs 9
cts 9
cp 1
rs 10
cc 1
nc 1
nop 4
crap 1
1
<?php
2
/**
3
 * This file is part of the ZBateson\MailMimeParser project.
4
 *
5
 * @license http://opensource.org/licenses/bsd-license.php BSD
6
 */
7
8
namespace ZBateson\MailMimeParser\Header;
9
10
use Psr\Log\LoggerInterface;
11
use ZBateson\MailMimeParser\MailMimeParser;
12
use ZBateson\MailMimeParser\Header\Consumer\GenericConsumerMimeLiteralPartService;
13
14
/**
15
 * Reads a generic header.
16
 *
17
 * Header's may contain mime-encoded parts, quoted parts, and comments.  The
18
 * string value is the combined value of all its parts.
19
 *
20
 * @author Zaahid Bateson
21
 */
22
class GenericHeader extends AbstractHeader
23
{
24 104
    public function __construct(
25
        string $name,
26
        string $value,
27
        ?LoggerInterface $logger = null,
28
        ?GenericConsumerMimeLiteralPartService $consumerService = null
29
    ) {
30 104
        $di = MailMimeParser::getGlobalContainer();
31 104
        parent::__construct(
32 104
            $logger ?? $di->get(LoggerInterface::class),
33 104
            $consumerService ?? $di->get(DateConsumerService::class),
0 ignored issues
show
Bug introduced by
The type ZBateson\MailMimeParser\Header\DateConsumerService was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
34 104
            $name,
35 104
            $value
36 104
        );
37 104
        parent::__construct($logger, $consumerService, $name, $value);
0 ignored issues
show
Bug introduced by
It seems like $logger can also be of type null; however, parameter $logger of ZBateson\MailMimeParser\...ctHeader::__construct() does only seem to accept Psr\Log\LoggerInterface, maybe add an additional type check? ( Ignorable by Annotation )

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

37
        parent::__construct(/** @scrutinizer ignore-type */ $logger, $consumerService, $name, $value);
Loading history...
Bug introduced by
It seems like $consumerService can also be of type null; however, parameter $consumerService of ZBateson\MailMimeParser\...ctHeader::__construct() does only seem to accept ZBateson\MailMimeParser\...nsumer\IConsumerService, maybe add an additional type check? ( Ignorable by Annotation )

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

37
        parent::__construct($logger, /** @scrutinizer ignore-type */ $consumerService, $name, $value);
Loading history...
38
    }
39
40 101
    public function getValue() : ?string
41
    {
42 101
        if (!empty($this->parts)) {
43 101
            return \implode('', \array_map(function($p) { return $p->getValue(); }, $this->parts));
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
Coding Style introduced by
Opening brace must be the last content on the line
Loading history...
Coding Style introduced by
It is generally recommended to place each PHP statement on a line by itself.

Let’s take a look at an example:

// Bad
$a = 5; $b = 6; $c = 7;

// Good
$a = 5;
$b = 6;
$c = 7;
Loading history...
44
        }
45
        return null;
46
    }
47
}
48