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

EngineFinder::find()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4

Importance

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