OptionFixture   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 53
ccs 10
cts 10
cp 1
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getAttributeCode() 0 3 1
A getOption() 0 3 1
A __construct() 0 4 1
A rollback() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace TddWizard\Fixtures\Catalog;
5
6
use Magento\Eav\Model\Entity\Attribute\Option as AttributeOption;
7
use Magento\Framework\Exception\LocalizedException;
8
9
/**
10
 * Class OptionFixture
11
 */
12
class OptionFixture
13
{
14
15
    /**
16
     * @var string
17
     */
18
    private $attributeCode;
19
20
    /**
21
     * @var AttributeOption
22
     */
23
    private $option;
24
25
    /**
26
     * OptionFixture constructor.
27
     *
28
     * @param AttributeOption $option
29
     * @param string $attributeCode
30
     */
31 9
    public function __construct(AttributeOption $option, string $attributeCode)
32
    {
33 9
        $this->attributeCode = $attributeCode;
34 9
        $this->option = $option;
35 9
    }
36
37
    /**
38
     * Get the attribute code.
39
     *
40
     * @return string
41
     */
42 6
    public function getAttributeCode(): string
43
    {
44 6
        return $this->attributeCode;
45
    }
46
47
    /**
48
     * Get the option.
49
     *
50
     * @return AttributeOption
51
     */
52 8
    public function getOption(): AttributeOption
53
    {
54 8
        return $this->option;
55
    }
56
57
    /**
58
     * Rollback the option(s).
59
     *
60
     * @throws LocalizedException
61
     */
62 2
    public function rollback(): void
63
    {
64 2
        OptionFixtureRollback::create()->execute($this);
65 2
    }
66
}
67