Issues (76)

src/Header/GenericHeader.php (6 issues)

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\Header\Consumer\GenericConsumerMimeLiteralPartService;
12
use ZBateson\MailMimeParser\MailMimeParser;
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
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
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...
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
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
Opening brace must be the last content on the line
Loading history...
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