Passed
Pull Request — master (#63)
by Laura
44:11 queued 10s
created

OptionFixture::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 4
rs 10
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
    public function __construct(AttributeOption $option, string $attributeCode)
32
    {
33
        $this->attributeCode = $attributeCode;
34
        $this->option = $option;
35
    }
36
37
    /**
38
     * Get the attribute code.
39
     *
40
     * @return string
41
     */
42
    public function getAttributeCode(): string
43
    {
44
        return $this->attributeCode;
45
    }
46
47
    /**
48
     * Get the option.
49
     *
50
     * @return AttributeOption
51
     */
52
    public function getOption(): AttributeOption
53
    {
54
        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