Passed
Pull Request — master (#18)
by
unknown
13:04 queued 09:21
created

CurrencyNameTrait::getCurrencyNameToken()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * File containing the {@see \Mailcode\Traits\Commands\Validation\CurrencyNameTrait} trait.
4
 *
5
 * @see \Mailcode\Traits\Commands\Validation\CurrencyNameTrait
6
 * @subpackage Validation
7
 * @package Mailcode
8
 */
9
10
declare(strict_types=1);
11
12
namespace Mailcode;
13
14
use Mailcode\Interfaces\Commands\Validation\NoTrackingInterface;
15
16
/**
17
 * Command validation drop-in: checks for the presence
18
 * of the `currency-name:` keyword in the command statement,
19
 * and sets the currency name enabled flag accordingly.
20
 *
21
 * @package Mailcode
22
 * @subpackage Validation
23
 * @author Olaf Böcker <[email protected]>
24
 *
25
 * @see NoTrackingInterface
26
 */
27
trait CurrencyNameTrait
28
{
29
    public function isCurrencyNameEnabled(): bool
30
    {
31
        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

31
        return $this->/** @scrutinizer ignore-call */ requireParams()
Loading history...
32
            ->getInfo()
33
            ->hasKeyword(Mailcode_Commands_Keywords::TYPE_CURRENCY_NAME);
34
    }
35
36
    /**
37
     * @param bool $enabled
38
     * @return $this
39
     * @throws Mailcode_Exception
40
     */
41
    public function setCurrencyNameEnabled(bool $enabled): self
42
    {
43
        $this->requireParams()
44
            ->getInfo()
45
            ->setKeywordEnabled(Mailcode_Commands_Keywords::TYPE_CURRENCY_NAME, $enabled);
46
47
        return $this;
48
    }
49
50
    public function getCurrencyNameToken(): ?Mailcode_Parser_Statement_Tokenizer_Token_Keyword
51
    {
52
        return $this->requireParams()
53
            ->getInfo()
54
            ->getKeywordsCollection()
55
            ->getByName(Mailcode_Commands_Keywords::TYPE_CURRENCY_NAME);
56
    }
57
}
58