Passed
Push — main ( 133894...47d353 )
by Sammy
06:22
created

Configuration::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 2
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace HexMakina\LeMarchand;
4
5
class Configuration
6
{
7
8
    public const RX_SETTINGS = '/^settings\./';
9
10
    public const RX_MVC = '/(Models|Controllers)\\\([a-zA-Z]+)(::class|::new)?/';
11
12
    public const RX_INTERFACE = '/([a-zA-Z]+)Interface$/';
13
14
15
    private $lament;
16
17
    public function __construct($configuration_string)
18
    {
19
        $this->lament = $configuration_string;
20
    }
21
22
    public function __toString(){
23
      return $this->lament;
24
    }
25
26
    public function isSettings()
27
    {
28
        return preg_match(self::RX_SETTINGS, $this->lament) === 1;
29
    }
30
31
    public function isInterface()
32
    {
33
        return preg_match(self::RX_INTERFACE, $this->lament) === 1;
34
    }
35
36
    public function isModelOrController()
37
    {
38
        return preg_match(self::RX_MVC, $this->lament) === 1;
39
    }
40
41
    public function getModelOrControllerName()
42
    {
43
        preg_match(self::RX_MVC, $this->lament, $m);
44
        return $m[1] . '\\' . $m[2];
45
    }
46
47
    public function hasClassNameModifier()
48
    {
49
        return strpos($this->lament, '::class') !== false;
50
    }
51
52
    public function hasNewInstanceModifier()
53
    {
54
        return strpos($this->lament, '::new') !== false;
55
    }
56
}
57