Passed
Push — main ( 3feea0...902010 )
by Gabriel
14:42
created

Namefy   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
eloc 12
c 1
b 0
f 0
dl 0
loc 58
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A strategy() 0 6 2
A model() 0 3 1
A from() 0 3 1
A controller() 0 3 1
A self() 0 7 2
A repository() 0 3 1
1
<?php
2
3
namespace ByTIC\Namefy;
4
5
/**
6
 * Class Namefy
7
 * @package ByTIC\Namefy
8
 */
9
class Namefy
10
{
11
    /**
12
     * @param null|string $name
13
     * @return Generator|Generator\HasStrategy|Strategies\AbstractStrategy|null
14
     */
15
    public static function strategy($name = null)
16
    {
17
        if ($name === null) {
18
            return static::self()->getStrategy();
19
        }
20
        return static::self()->setStrategy($name);
21
    }
22
23
    /**
24
     * @param string $name
25
     * @return Name
26
     */
27
    public static function model($name): Name
28
    {
29
        return static::from($name, 'model');
30
    }
31
32
    /**
33
     * @param string $name
34
     * @return Name
35
     */
36
    public static function repository($name): Name
37
    {
38
        return static::from($name, 'repository');
39
    }
40
41
    /**
42
     * @param string $name
43
     * @return Name
44
     */
45
    public static function controller($name): Name
46
    {
47
        return static::from($name, 'controller');
48
    }
49
50
    /**
51
     * @param string $name
52
     * @param string $type
53
     * @return Name
54
     */
55
    protected static function from(string $name, $type): Name
56
    {
57
        return static::self()->from($name, $type);
58
    }
59
60
    protected static function self(): Generator
61
    {
62
        static $instance;
63
        if (!($instance instanceof Generator)) {
64
            $instance = new Generator();
65
        }
66
        return $instance;
67
    }
68
}
69