Passed
Push — master ( 0f91e9...e0eb75 )
by Sebastian
03:48
created

NoTrackingTrait::setTrackingEnabled()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 7
rs 10
1
<?php
2
/**
3
 * File containing the {@see \Mailcode\Traits\Commands\Validation\NoTrackingTrait} trait.
4
 *
5
 * @see \Mailcode\Traits\Commands\Validation\NoTrackingTrait
6
 * @subpackage Validation
7
 * @package Mailcode
8
 */
9
10
declare(strict_types=1);
11
12
namespace Mailcode\Traits\Commands\Validation;
13
14
use Mailcode\Interfaces\Commands\Validation\NoTrackingInterface;
15
use Mailcode\Mailcode_Commands_Keywords;
16
use Mailcode\Mailcode_Exception;
17
use Mailcode\Mailcode_Parser_Statement_Tokenizer_Token_Keyword;
18
use Mailcode\Mailcode_Parser_Statement_Validator;
19
use phpDocumentor\Descriptor\Interfaces\FunctionInterface;
0 ignored issues
show
Bug introduced by
The type phpDocumentor\Descriptor...faces\FunctionInterface 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...
20
use phpDocumentor\Reflection\Utils;
21
22
/**
23
 * Command validation drop-in: checks for the presence
24
 * of the `no-tracking:` keyword in the command statement,
25
 * and sets the tracking enabled flag accordingly.
26
 *
27
 * @package Mailcode
28
 * @subpackage Validation
29
 * @author Sebastian Mordziol <[email protected]>
30
 *
31
 * @see NoTrackingInterface
32
 */
33
trait NoTrackingTrait
34
{
35
    public function isTrackingEnabled() : bool
36
    {
37
        return !$this->requireParams()
0 ignored issues
show
Bug introduced by
It seems like requireParams() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

37
        return !$this->/** @scrutinizer ignore-call */ requireParams()
Loading history...
38
            ->getInfo()
39
            ->hasKeyword(Mailcode_Commands_Keywords::TYPE_NO_TRACKING);
40
    }
41
42
    /**
43
     * @param bool $enabled
44
     * @return $this
45
     * @throws Mailcode_Exception
46
     */
47
    public function setTrackingEnabled(bool $enabled) : self
48
    {
49
        $this->requireParams()
50
            ->getInfo()
51
            ->setKeywordEnabled(Mailcode_Commands_Keywords::TYPE_NO_TRACKING, !$enabled);
52
53
        return $this;
54
    }
55
56
    public function getNoTrackingToken() : ?Mailcode_Parser_Statement_Tokenizer_Token_Keyword
57
    {
58
        return $this->requireParams()
59
            ->getInfo()
60
            ->getKeywordsCollection()
61
            ->getByName(Mailcode_Commands_Keywords::TYPE_NO_TRACKING);
62
    }
63
}
64