1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace HexMakina\TightORM; |
4
|
|
|
|
5
|
|
|
use HexMakina\Crudites\Crudites; |
6
|
|
|
use HexMakina\Crudites\Row; |
|
|
|
|
7
|
|
|
use HexMakina\Crudites\CruditesException; |
8
|
|
|
use HexMakina\BlackBox\Database\TableInterface; |
|
|
|
|
9
|
|
|
use HexMakina\BlackBox\Database\SelectInterface; |
10
|
|
|
|
11
|
|
|
abstract class Model extends Row |
12
|
|
|
{ |
13
|
|
|
// returns the value of the PK, whatever it's name |
14
|
|
|
// returns the name of the PK, if $mode === 'name' |
15
|
|
|
public function id($mode = null) |
16
|
|
|
{ |
17
|
|
|
$primary_key = $this->table()->autoIncrementedPrimaryKey(); |
18
|
|
|
|
19
|
|
|
if (is_null($primary_key) && count($pks = $this->table()->primaryKeys()) == 1) { |
20
|
|
|
$primary_key = current($pks); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
return $mode === 'name' ? $primary_key->name() : $this->get($primary_key->name()); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
// Model might have properties, if not, use row data |
27
|
|
|
public function get($prop_name) |
28
|
|
|
{ |
29
|
|
|
if (property_exists($this, $prop_name) === true) { |
30
|
|
|
return $this->$prop_name; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
return parent::get($prop_name); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
// Model might have properties, if not, use row data |
37
|
|
|
public function set($prop_name, $value): void |
38
|
|
|
{ |
39
|
|
|
if (property_exists($this, $prop_name) === true) { |
40
|
|
|
$this->$prop_name = $value; |
41
|
|
|
} else { |
42
|
|
|
parent::set($prop_name, $value); |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths