Repository navigation
Expand file tree
/
Copy pathModelOption.php
More file actions
193 lines (149 loc) · 3.84 KB
/
Copy pathModelOption.php
File metadata and controls
193 lines (149 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://hyperf.wiki
* @contact [email protected]
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
namespace Hyperf\Database\Commands;
class ModelOption
{
public const PROPERTY_SNAKE_CASE = 0;
public const PROPERTY_CAMEL_CASE = 1;
protected ?string $pool = null;
protected ?string $path = null;
protected ?bool $forceCasts = null;
protected ?string $prefix = null;
protected ?string $inheritance = null;
protected ?string $uses = null;
protected ?bool $refreshFillable = null;
protected ?bool $withComments = null;
protected ?bool $withIde = null;
protected array $tableMapping = [];
protected array $ignoreTables = [];
protected array $visitors = [];
protected int $propertyCase = self::PROPERTY_SNAKE_CASE;
public function getPool(): string
{
return $this->pool;
}
public function setPool(string $pool): static
{
$this->pool = $pool;
return $this;
}
public function getPath(): string
{
return $this->path;
}
public function setPath(string $path): static
{
$this->path = $path;
return $this;
}
public function isForceCasts(): bool
{
return $this->forceCasts;
}
public function setForceCasts(bool $forceCasts): static
{
$this->forceCasts = $forceCasts;
return $this;
}
public function getPrefix(): string
{
return $this->prefix;
}
public function setPrefix(string $prefix): static
{
$this->prefix = $prefix;
return $this;
}
public function getInheritance(): string
{
return $this->inheritance;
}
public function setInheritance(string $inheritance): static
{
$this->inheritance = $inheritance;
return $this;
}
public function getUses(): string
{
return $this->uses;
}
public function setUses(string $uses): static
{
$this->uses = $uses;
return $this;
}
public function isRefreshFillable(): bool
{
return $this->refreshFillable;
}
public function setRefreshFillable(bool $refreshFillable): static
{
$this->refreshFillable = $refreshFillable;
return $this;
}
public function getTableMapping(): array
{
return $this->tableMapping;
}
public function setTableMapping(array $tableMapping): static
{
foreach ($tableMapping as $item) {
[$key, $name] = explode(':', $item);
$this->tableMapping[$key] = $name;
}
return $this;
}
public function getIgnoreTables(): array
{
return $this->ignoreTables;
}
public function setIgnoreTables(array $ignoreTables): static
{
$this->ignoreTables = $ignoreTables;
return $this;
}
public function isWithComments(): bool
{
return $this->withComments;
}
public function setWithComments(bool $withComments): static
{
$this->withComments = $withComments;
return $this;
}
public function isWithIde(): bool
{
return $this->withIde;
}
public function setWithIde(bool $withIde): ModelOption
{
$this->withIde = $withIde;
return $this;
}
public function getVisitors(): array
{
return $this->visitors;
}
public function setVisitors(array $visitors): static
{
$this->visitors = $visitors;
return $this;
}
public function isCamelCase(): bool
{
return $this->propertyCase === self::PROPERTY_CAMEL_CASE;
}
public function setPropertyCase($propertyCase): static
{
$this->propertyCase = (int) $propertyCase;
return $this;
}
}