Passed
Push — master ( 87ba60...d80a49 )
by Alain
02:43
created

BaseViewFinder::getFindablesConfigKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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