AddActionTypeTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 14
c 0
b 0
f 0
dl 0
loc 31
ccs 16
cts 16
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A addActionType() 0 20 2
1
<?php
2
3
/**
4
 * This file is part of riesenia/pohoda package.
5
 *
6
 * Licensed under the MIT License
7
 * (c) RIESENIA.com
8
 */
9
10
declare(strict_types=1);
11
12
namespace Riesenia\Pohoda\Common;
13
14
use Riesenia\Pohoda\Type\ActionType;
15
16
/**
17
 * @property array<string, mixed> $data
18
 */
19
trait AddActionTypeTrait
20
{
21
    /**
22
     * Add action type.
23
     *
24
     * @param string      $type
25
     * @param mixed|null  $filter
26
     * @param string|null $agenda
27
     *
28
     * @return self
29
     */
30 8
    public function addActionType(string $type, mixed $filter = null, ?string $agenda = null): self
31
    {
32 8
        if (isset($this->data['actionType'])) {
33 1
            throw new \LogicException('Duplicate action type.');
34
        }
35
36 8
        $actionType = new ActionType(
37 8
            $this->namespacesPaths,
38 8
            $this->sanitizeEncoding,
39 8
            $this->companyRegistrationNumber,
40 8
            $this->resolveOptions,
41 8
            $this->normalizerFactory,
42 8
        );
43 8
        $this->data['actionType'] = $actionType->setDirectionalVariable($this->useOneDirectionalVariables)->setData([
44 8
            'type' => $type,
45 8
            'filter' => $filter,
46 8
            'agenda' => $agenda,
47 8
        ]);
48
49 8
        return $this;
50
    }
51
}
52