AddParameterTrait   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
eloc 14
dl 0
loc 29
c 0
b 0
f 0
ccs 15
cts 15
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A addParameter() 0 18 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace kalanis\Pohoda\Common;
6
7
use kalanis\Pohoda\Type;
8
9
/**
10
 * @property object{
11
 *     parameters: array<Type\Parameter>
12
 * } $data
13
 */
14
trait AddParameterTrait
15
{
16
    /**
17
     * Set user-defined parameter.
18
     *
19
     * @param string     $name  (can be set without preceding VPr / RefVPr)
20
     * @param Type\Enums\ParameterTypeEnum|string $type
21
     * @param mixed      $value
22
     * @param mixed|null $list
23
     * @return self
24
     */
25 15
    public function addParameter(string $name, Type\Enums\ParameterTypeEnum|string $type, mixed $value, mixed $list = null): self
26
    {
27 15
        $parameter = new Type\Parameter(
28 15
            $this->dependenciesFactory,
29 15
        );
30 15
        $dto = new Type\Dtos\ParameterDto();
31 15
        $dto->name = $name;
32 15
        $dto->type = $type;
33 15
        $dto->value = $value;
34 15
        $dto->list = $list;
35
36 15
        $parameter
37 15
            ->setDirectionalVariable($this->useOneDirectionalVariables)
38 15
            ->setResolveOptions($this->resolveOptions)
39 15
            ->setData($dto);
40 15
        $this->data->parameters[] = $parameter;
41
42 15
        return $this;
43
    }
44
}
45