AbstractStrategy::to()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
namespace ByTIC\Namefy\Strategies;
4
5
use ByTIC\Namefy\Name;
6
7
/**
8
 * Class AbstractStrategy
9
 * @package ByTIC\Namefy\Strategies
10
 */
11
abstract class AbstractStrategy
12
{
13
    /**
14
     * @param $type
15
     * @param $value
16
     * @param Name $name
17
     * @return mixed
18
     */
19
    public function from($type, $value, Name $name)
20
    {
21
        $method = 'from' . ucfirst($type);
22
        return $this->$method($value, $name);
23
    }
24
25
    /**
26
     * @param $slug
27
     * @return string
28
     */
29
    abstract public function fromRepository($slug, Name $name);
30
31
    /**
32
     * @param $slug
33
     * @return string
34
     */
35
    abstract public function fromModel($slug, Name $name);
36
37
    /**
38
     * @param $slug
39
     * @return string
40
     */
41
    abstract public function fromController($slug, Name $name);
42
43
    /**
44
     * @param $type
45
     * @param $value
46
     * @return mixed
47
     */
48
    public function to($type, $value)
49
    {
50
        $method = 'to' . ucfirst($type);
51
        return $this->$method($value);
52
    }
53
54
    /**
55
     * @param Name $name
56
     * @return string
57
     */
58
    abstract public function toModel(Name $name);
59
60
    /**
61
     * @param Name $name
62
     * @return string
63
     */
64
    abstract public function toController(Name $name);
65
66
    /**
67
     * @param Name $name
68
     * @return string
69
     */
70
    abstract public function toRepository(Name $name);
71
}
72