CategoryFixture   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 58.33%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 8
c 2
b 0
f 0
dl 0
loc 35
ccs 7
cts 12
cp 0.5833
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A rollback() 0 3 1
A getId() 0 3 1
A getCategory() 0 3 1
A getUrlKey() 0 5 1
A __construct() 0 3 1
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 12
    public function __construct(CategoryInterface $category)
25
    {
26 12
        $this->category = $category;
27 12
    }
28
29 11
    public function getId(): int
30
    {
31 11
        return (int) $this->category->getId();
32
    }
33
34
    public function getUrlKey(): string
35
    {
36
        /** @var Category $category */
37
        $category = $this->category;
38
        return (string)$category->getUrlKey();
39
    }
40
41
    public function rollback(): void
42
    {
43
        CategoryFixtureRollback::create()->execute($this);
44
    }
45
}
46