Passed
Pull Request — master (#52)
by Fabian
19:55
created

CategoryFixture::rollback()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
3
namespace TddWizard\Fixtures\Catalog;
4
5
use Magento\Catalog\Api\Data\CategoryInterface;
6
use Magento\Catalog\Model\Category;
7
8
class CategoryFixture
9
{
10
    /**
11
     * @var CategoryInterface
12
     */
13
    private $category;
14
15
    /**
16
     * @return CategoryInterface
17
     */
18 1
    public function getCategory(): CategoryInterface
19
    {
20 1
        return $this->category;
21
    }
22
23 11
    public function __construct(CategoryInterface $category)
24
    {
25 11
        $this->category = $category;
26 11
    }
27
28 10
    public function getId(): int
29
    {
30 10
        return $this->category->getId();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->category->getId() could return the type null which is incompatible with the type-hinted return integer. Consider adding an additional type-check to rule them out.
Loading history...
31
    }
32
33
    public function getUrlKey(): string
34
    {
35
        /** @var Category $category */
36
        $category = $this->category;
37
        return $category->getUrlKey();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $category->getUrlKey() could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
38
    }
39
40
    public function rollback(): void
41
    {
42
        CategoryFixtureRollback::create()->execute($this);
43
    }
44
}
45