Completed
Push — master ( a5022e...49928c )
by Fabian
14s queued 10s
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
declare(strict_types=1);
3
4
namespace TddWizard\Fixtures\Catalog;
5
6
use Magento\Catalog\Api\Data\CategoryInterface;
7
use Magento\Catalog\Model\Category;
8
9
class CategoryFixture
10
{
11
    /**
12
     * @var CategoryInterface
13
     */
14
    private $category;
15
16
    /**
17
     * @return CategoryInterface
18
     */
19 1
    public function getCategory(): CategoryInterface
20
    {
21 1
        return $this->category;
22
    }
23
24 11
    public function __construct(CategoryInterface $category)
25
    {
26 11
        $this->category = $category;
27 11
    }
28
29 10
    public function getId(): int
30
    {
31 10
        return (int) $this->category->getId();
32
    }
33
34
    public function getUrlKey(): string
35
    {
36
        /** @var Category $category */
37
        $category = $this->category;
38
        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...
39
    }
40
41
    public function rollback(): void
42
    {
43
        CategoryFixtureRollback::create()->execute($this);
44
    }
45
}
46