Completed
Pull Request — master (#6)
by Willem
08:10 queued 05:05
created

CustomLayoutManager::fakeAvailableFiles()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 4
c 2
b 0
f 1
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\Cms\Api\Data\PageInterface;
7
8
/**
9
 * Manager allowing to fake available files.
10
 */
11
class CustomLayoutManager extends \Magento\TestFramework\Cms\Model\CustomLayoutManager
0 ignored issues
show
Bug introduced by
The type Magento\TestFramework\Cm...del\CustomLayoutManager 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 string[][]
15
     */
16
    private $files = [];
17
18
    /**
19
     * Fake available files for given page.
20
     *
21
     * Pass null to unassign fake files.
22
     *
23
     * @param int $forPageId
24
     * @param string[]|null $files
25
     * @return void
26
     */
27
    public function fakeAvailableFiles(int $forPageId, ?array $files): void
28
    {
29
        if ($files === null) {
0 ignored issues
show
introduced by
The condition $files === null is always false.
Loading history...
30
            unset($this->files[$forPageId]);
31
        } else {
32
            $this->files[$forPageId] = $files;
33
        }
34
    }
35
36
    /**
37
     * Fetches fake/mock files added through $this->fakeAvailableFiles()
38
     *
39
     * @param PageInterface $page
40
     * @return array
41
     */
42
    public function fetchAvailableFiles(PageInterface $page): array
43
    {
44
        if (array_key_exists(0, $this->files)) {
45
            return $this->files[0];
46
        }
47
48
        return parent::fetchAvailableFiles($page);
49
    }
50
}
51