Total Complexity | 6 |
Total Lines | 83 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | abstract class BaseDefinition implements DefinitionInterface |
||
8 | { |
||
9 | /** |
||
10 | * Model table. |
||
11 | * |
||
12 | * @var string |
||
13 | */ |
||
14 | protected $table; |
||
15 | |||
16 | /** |
||
17 | * Field data. |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | protected $field; |
||
22 | |||
23 | /** |
||
24 | * BaseDefinition constructor. |
||
25 | * |
||
26 | * @param string $table |
||
27 | * @param array $field |
||
28 | * @return void |
||
29 | */ |
||
30 | public function __construct($table, $field) |
||
31 | { |
||
32 | $this->table = $table; |
||
33 | |||
34 | $this->field = $field; |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * {@inheritdoc} |
||
39 | */ |
||
40 | abstract public function modelGetter(); |
||
41 | |||
42 | /** |
||
43 | * Return normalized ID of current field. |
||
44 | * |
||
45 | * @return string |
||
46 | */ |
||
47 | protected function id(): string |
||
48 | { |
||
49 | return $this->field['id']; |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Return studly case ID of current field. |
||
54 | * |
||
55 | * @return string |
||
56 | */ |
||
57 | protected function studlyId(): string |
||
58 | { |
||
59 | return Str::studly($this->id()); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * Return snake case ID of current field. |
||
64 | * |
||
65 | * @return string |
||
66 | */ |
||
67 | protected function snakeId(): string |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * Write stub to destination path with given string replacements. |
||
74 | * |
||
75 | * Return relative base path of destination path. |
||
76 | * |
||
77 | * @param string $stubPath |
||
78 | * @param array $replacements |
||
79 | * @return string |
||
80 | */ |
||
81 | public static function getStub(string $stubPath, array $replacements = []): string |
||
90 | } |
||
91 | } |
||
92 |