Passed
Push — master ( 3f1e0c...bf7a69 )
by Aleksandr
02:11
created

Value   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 89
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 27
dl 0
loc 89
ccs 34
cts 34
cp 1
rs 10
c 1
b 1
f 0
wmc 16

15 Methods

Rating   Name   Duplication   Size   Complexity  
A setType() 0 3 1
A getType() 0 3 1
A isEmptyValue() 0 3 1
A isLineIndex() 0 3 1
A getValue() 0 3 1
A setLineIndex() 0 3 1
A getEntityKey() 0 3 1
A getLineIndex() 0 3 1
A setEntityKey() 0 3 1
A isEntityKey() 0 3 1
A setValue() 0 7 2
A getAttributeName() 0 3 1
A setAttributeName() 0 3 1
A setAttributeKey() 0 3 1
A getAttributeKey() 0 3 1
1
<?php
2
/**
3
 * This file is part of the eav package.
4
 * @author    Aleksandr Drobotik <[email protected]>
5
 * @copyright 2023 Aleksandr Drobotik
6
 * @license   https://opensource.org/license/mit  The MIT License
7
 */
8
declare(strict_types=1);
9
10
namespace Drobotik\Eav\Import\Content;
11
12
use Drobotik\Eav\Enum\ATTR_TYPE;
13
use Drobotik\Eav\Trait\SingletonsTrait;
14
15
class Value
16
{
17
    use SingletonsTrait;
18
19
    private mixed $value;
20
    private int $attributeKey;
21
    private string $attributeName;
22
    private ?int $entityKey = null;
23
    private int  $lineIndex;
24
25
    private ATTR_TYPE $type;
26
27 1
    public function setType(ATTR_TYPE $type): void
28
    {
29 1
        $this->type = $type;
30
    }
31
32 1
    public function getType() : ATTR_TYPE
33
    {
34 1
        return $this->type;
35
    }
36
37 1
    public function getValue()
38
    {
39 1
        return $this->value;
40
    }
41
42 2
    public function setValue(mixed $value): void
43
    {
44 2
        $type = $this->getType();
45 2
        $parser = $this->makeValueParser();
46 2
        $this->value = $value == ''
47 1
            ? ''
48 2
            : $parser->parse($type, $value);
49
    }
50
51 1
    public function isEmptyValue(): bool
52
    {
53 1
        return $this->value == '';
54
    }
55
56 1
    public function getEntityKey() : ?int
57
    {
58 1
        return $this->entityKey;
59
    }
60
61 1
    public function setEntityKey(int $key): void
62
    {
63 1
        $this->entityKey = $key;
64
    }
65
66 1
    public function isEntityKey() : bool
67
    {
68 1
        return !is_null($this->entityKey);
69
    }
70
71 1
    public function setLineIndex(int $index)
72
    {
73 1
        $this->lineIndex = $index;
74
    }
75
76 1
    public function getLineIndex() : int
77
    {
78 1
        return $this->lineIndex;
79
    }
80
81 1
    public function isLineIndex() : bool
82
    {
83 1
        return isset($this->lineIndex);
84
    }
85
86 1
    public function getAttributeKey() : int
87
    {
88 1
        return $this->attributeKey;
89
    }
90
91 1
    public function setAttributeKey(int $key): void
92
    {
93 1
        $this->attributeKey = $key;
94
    }
95
96 1
    public function getAttributeName() : string
97
    {
98 1
        return $this->attributeName;
99
    }
100
101 1
    public function setAttributeName(string $name): void
102
    {
103 1
        $this->attributeName = $name;
104
    }
105
}