1 | <?php |
||
10 | class OracleEloquent extends Model |
||
11 | { |
||
12 | /** |
||
13 | * List of binary (blob) columns |
||
14 | * |
||
15 | * @var array |
||
16 | */ |
||
17 | protected $binaries = []; |
||
18 | |||
19 | /** |
||
20 | * @var array |
||
21 | */ |
||
22 | protected $wrapBinaries = []; |
||
23 | |||
24 | /** |
||
25 | * Sequence name variable |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $sequence = null; |
||
30 | |||
31 | /** |
||
32 | * Get model's sequence name |
||
33 | * |
||
34 | * @return string |
||
35 | */ |
||
36 | public function getSequenceName() |
||
37 | { |
||
38 | if ($this->sequence) { |
||
39 | return $this->sequence; |
||
40 | } |
||
41 | |||
42 | return $this->getTable() . '_' . $this->getKeyName() . '_seq'; |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * Set sequence name |
||
47 | * |
||
48 | * @param string $name |
||
49 | * @return string |
||
50 | */ |
||
51 | public function setSequenceName($name) |
||
55 | |||
56 | /** |
||
57 | * Update the model in the database. |
||
58 | * |
||
59 | * @param array $attributes |
||
60 | * @param array $options |
||
61 | * @return bool|int |
||
62 | */ |
||
63 | public function update(array $attributes = [], array $options = []) |
||
77 | |||
78 | /** |
||
79 | * wrap binaries to each attributes |
||
80 | * |
||
81 | * @param array $attributes |
||
82 | * @return array |
||
83 | */ |
||
84 | public function wrapBinary(&$attributes) |
||
100 | |||
101 | /** |
||
102 | * Check if attributes contains binary field |
||
103 | * |
||
104 | * @param array $attributes |
||
105 | * @return boolean |
||
106 | */ |
||
107 | public function checkBinary(array $attributes) |
||
118 | |||
119 | /** |
||
120 | * Get the table qualified key name. |
||
121 | * |
||
122 | * @return string |
||
123 | */ |
||
124 | public function getQualifiedKeyName() |
||
137 | |||
138 | /** |
||
139 | * Get a new query builder instance for the connection. |
||
140 | * |
||
141 | * @return \Yajra\Oci8\Query\OracleBuilder |
||
142 | */ |
||
143 | protected function newBaseQueryBuilder() |
||
151 | |||
152 | /** |
||
153 | * Perform a model update operation. |
||
154 | * |
||
155 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
156 | * @param array $options |
||
157 | * @return boolean |
||
158 | */ |
||
159 | protected function performUpdate(Builder $query, array $options = []) |
||
194 | |||
195 | /** |
||
196 | * @param Builder $query |
||
197 | * @param array $dirty |
||
198 | * @param array $options |
||
199 | */ |
||
200 | protected function updateBinary(Builder $query, $dirty, $options = []) |
||
208 | |||
209 | /** |
||
210 | * Perform a model insert operation. |
||
211 | * |
||
212 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
213 | * @param array $options |
||
214 | * @return bool |
||
215 | */ |
||
216 | protected function performInsert(Builder $query, array $options = []) |
||
262 | |||
263 | /** |
||
264 | * Insert the given attributes and set the ID on the model. |
||
265 | * |
||
266 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
267 | * @param array $attributes |
||
268 | * @return int|void |
||
269 | */ |
||
270 | protected function insertAndSetId(Builder $query, $attributes) |
||
280 | } |
||
281 |
If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.
Let’s take a look at an example:
Our function
my_function
expects aPost
object, and outputs the author of the post. The base classPost
returns a simple string and outputting a simple string will work just fine. However, the child classBlogPost
which is a sub-type ofPost
instead decided to return anobject
, and is therefore violating the SOLID principles. If aBlogPost
were passed tomy_function
, PHP would not complain, but ultimately fail when executing thestrtoupper
call in its body.