DriverClassValidator   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 37
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A isValidDriverClass() 0 16 5
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
}