Completed
Pull Request — master (#63)
by Laura
18:04
created

OptionFixture   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A rollback() 0 3 1
A getAttributeCode() 0 3 1
A getOption() 0 3 1
A __construct() 0 4 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 4
    public function __construct(AttributeOption $option, string $attributeCode)
32
    {
33 4
        $this->attributeCode = $attributeCode;
34 4
        $this->option = $option;
35 4
    }
36
37
    /**
38
     * Get the attribute code.
39
     *
40
     * @return string
41
     */
42 4
    public function getAttributeCode(): string
43
    {
44 4
        return $this->attributeCode;
45
    }
46
47
    /**
48
     * Get the option.
49
     *
50
     * @return AttributeOption
51
     */
52 4
    public function getOption(): AttributeOption
53
    {
54 4
        return $this->option;
55
    }
56
57
    /**
58
     * Rollback the option(s).
59
     *
60
     * @throws LocalizedException
61
     */
62
    public function rollback(): void
63
    {
64
        OptionFixtureRollback::create()->execute($this);
65
    }
66
}
67