Completed
Push — tests ( c1270e...84083a )
by Willem
03:47
created

CustomLayoutManager::fetchAvailableFiles()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 3
c 1
b 0
f 1
dl 0
loc 7
rs 10
cc 2
nc 2
nop 1
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
        var_dump('added');
0 ignored issues
show
Security Debugging Code introduced by
var_dump('added') looks like debug code. Are you sure you do not want to remove it?
Loading history...
30
        if ($files === null) {
0 ignored issues
show
introduced by
The condition $files === null is always false.
Loading history...
31
            unset($this->files[$forPageId]);
32
        } else {
33
            $this->files[$forPageId] = $files;
34
        }
35
    }
36
37
    /**
38
     * Fetches fake/mock files added through $this->fakeAvailableFiles()
39
     *
40
     * @param PageInterface $page
41
     * @return array
42
     */
43
    public function fetchAvailableFiles(PageInterface $page): array
44
    {
45
        if (array_key_exists(0, $this->files)) {
46
            return $this->files[0];
47
        }
48
49
        return parent::fetchAvailableFiles($page);
50
    }
51
}
52