Passed
Push — master ( 6d9d43...921f98 )
by Alain
02:46
created

ViewFinder::initializeViews()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 3
nc 2
nop 2
crap 2
1
<?php
2
/**
3
 * Bright Nucleus View Component.
4
 *
5
 * @package   BrightNucleus\View
6
 * @author    Alain Schlesser <[email protected]>
7
 * @license   MIT
8
 * @link      http://www.brightnucleus.com/
9
 * @copyright 2016 Alain Schlesser, Bright Nucleus
10
 */
11
12
namespace BrightNucleus\View\View;
13
14
use BrightNucleus\View\Engine\EngineInterface;
15
use BrightNucleus\View\Support\AbstractFinder;
16
17
/**
18
 * Class ViewFinder.
19
 *
20
 * @since   0.1.0
21
 *
22
 * @package BrightNucleus\View\View
23
 * @author  Alain Schlesser <[email protected]>
24
 */
25
class ViewFinder extends AbstractFinder
26
{
27
28
    /**
29
     * Find a result based on a specific criteria.
30
     *
31
     * @since 0.1.0
32
     *
33
     * @param array                $criteria Criteria to search for.
34
     * @param EngineInterface|null $engine   Optional. Engine to use with the view.
35
     *
36
     * @return ViewInterface View that was found.
37
     */
38 17
    public function find(array $criteria, EngineInterface $engine = null)
39
    {
40 17
        $uri = $criteria[0];
41
42 17
        $this->initializeFindables([$uri, $engine]);
43
44 17
        foreach ($criteria as $entry) {
45 17
            foreach ($this->findables as $viewObject) {
46 17
                if ($viewObject->canHandle($entry)) {
47 17
                    return $viewObject;
48
                }
49
            }
50
        }
51
52
        return $this->getNullObject();
53
    }
54
55
    /**
56
     * Get the config key for the Findables definitions.
57
     *
58
     * @since 0.1.0
59
     *
60
     * @return string Config key use to define the Findables.
61
     */
62 8
    protected function getFindablesConfigKey()
63
    {
64 8
        return 'Views';
65
    }
66
}
67