Passed
Push — main ( 47d353...677be7 )
by Sammy
01:35
created

Configuration::configurationString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
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->configurationString();
24
    }
25
26
    public function configurationString(){
27
      return $this->lament;
28
    }
29
30
    public function isSettings()
31
    {
32
        return preg_match(self::RX_SETTINGS, $this->lament) === 1;
33
    }
34
35
    public function isInterface()
36
    {
37
        return preg_match(self::RX_INTERFACE, $this->lament) === 1;
38
    }
39
40
    public function isModelOrController()
41
    {
42
        return preg_match(self::RX_MVC, $this->lament) === 1;
43
    }
44
45
    public function getModelOrControllerName()
46
    {
47
        preg_match(self::RX_MVC, $this->lament, $m);
48
        return $m[1] . '\\' . $m[2];
49
    }
50
51
    public function hasClassNameModifier()
52
    {
53
        return strpos($this->lament, '::class') !== false;
54
    }
55
56
    public function hasNewInstanceModifier()
57
    {
58
        return strpos($this->lament, '::new') !== false;
59
    }
60
}
61