DriverClassValidator::isValidDriverClass()   A
last analyzed

Complexity

Conditions 5
Paths 4

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4222
c 0
b 0
f 0
cc 5
nc 4
nop 1
1
<?php
2
3
namespace Bex\Behat\ExtensionDriverLocator;
4
5
use Bex\Behat\ExtensionDriverLocator\DriverInterface;
6
7
class DriverClassValidator
8
{
9
    /**
10
     * @var string
11
     */
12
    private $parent;
13
14
    /**
15
     * @param string $parent
16
     */
17
    public function __construct($parent = '')
18
    {
19
        $this->parent = $parent;
20
    }
21
22
    /**
23
     * @param  string  $className
24
     *
25
     * @return boolean
26
     */
27
    public function isValidDriverClass($className)
28
    {
29
        if (!class_exists($className)) {
30
            return false;
31
        }
32
33
        if (!is_subclass_of($className, 'Bex\\Behat\\ExtensionDriverLocator\\DriverInterface')) {
34
            return false;
35
        }
36
37
        if (!empty($this->parent) && !is_subclass_of($className, $this->parent)) {
38
            return false;
39
        }
40
41
        return true;
42
    }
43
}