Completed
Push — master ( d80aef...0536a3 )
by Willem
13s queued 12s
created

setCategoryFakeFiles()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 2
nc 2
nop 2
1
<?php
2
declare(strict_types=1);
3
4
namespace IntegerNet\GlobalCustomLayout\Test\Util;
5
6
use Magento\Catalog\Api\Data\CategoryInterface;
7
8
/**
9
 * Easy way to fake available files.
10
 */
11
class CategoryLayoutUpdateManager extends \Magento\TestFramework\Catalog\Model\CategoryLayoutUpdateManager
0 ignored issues
show
Bug introduced by
The type Magento\TestFramework\Ca...goryLayoutUpdateManager was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
{
13
    /**
14
     * @var array Keys are category IDs, values - file names.
15
     */
16
    private $fakeFiles = [];
17
18
    /**
19
     * Supply fake files for a category.
20
     *
21
     * @param int $forCategoryId
22
     * @param string[]|null $files Pass null to reset.
23
     */
24
    public function setCategoryFakeFiles(int $forCategoryId, ?array $files): void
25
    {
26
        if ($files === null) {
0 ignored issues
show
introduced by
The condition $files === null is always false.
Loading history...
27
            unset($this->fakeFiles[$forCategoryId]);
28
        } else {
29
            $this->fakeFiles[$forCategoryId] = $files;
30
        }
31
    }
32
33
    /**
34
     * Fetches fake/mock files added through $this->setCategoryFakeFiles()
35
     *
36
     * @param CategoryInterface $category
37
     * @return array
38
     */
39
    public function fetchAvailableFiles(CategoryInterface $category): array
40
    {
41
        if (array_key_exists(0, $this->fakeFiles)) {
42
            return $this->fakeFiles[0];
43
        }
44
        return parent::fetchAvailableFiles($category);
45
    }
46
}
47