Passed
Branch v1.4.0 (ac3196)
by Wanderson
01:13
created

Orm::limit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Win\Database;
4
5
use Win\Database\Orm\Traits\DebugTrait;
6
use Win\Database\Orm\Traits\OrderTrait;
7
use Win\Database\Orm\Traits\ReadTrait;
8
use Win\Database\Orm\Traits\WriteTrait;
9
use Win\Database\Sql\Queries\Select;
10
use Win\Singleton\SingletonTrait;
11
12
/**
13
 * Object Relational Mapping
14
 */
15
abstract class Orm
16
{
17
	/** @var string */
18
	protected $table;
19
20
	/** @var Connection */
21
	protected static $db;
22
23
	use SingletonTrait {
24
		__construct as finalConstruct;
25
	}
26
27
	use OrderTrait;
0 ignored issues
show
Bug introduced by
The trait Win\Database\Orm\Traits\OrderTrait requires the property $orderBy which is not provided by Win\Database\Orm.
Loading history...
28
	use DebugTrait;
29
	use ReadTrait;
0 ignored issues
show
introduced by
The trait Win\Database\Orm\Traits\ReadTrait requires some properties which are not provided by Win\Database\Orm: $where, $limit
Loading history...
30
	use WriteTrait;
0 ignored issues
show
Bug introduced by
The trait Win\Database\Orm\Traits\WriteTrait requires the property $where which is not provided by Win\Database\Orm.
Loading history...
31
32
	/** @var Select */
33
	private $query;
34
35
	public function __construct()
36
	{
37
		$this->query = new Select($this);
38
	}
39
40
	/** @param Connection $db */
41
	public static function setConnection(Connection $db)
42
	{
43
		static::$db = $db;
44
	}
45
46
	/** @return Connection */
47
	public static function getConnection()
48
	{
49
		return static::$db;
50
	}
51
52
	/**
53
	 * @param mixed[] $row
54
	 * @return Model
0 ignored issues
show
Bug introduced by
The type Win\Database\Model was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
55
	 */
56
	abstract public function mapModel($row);
57
58
	/**
59
	 * @param Model $model
60
	 * @return mixed[]
61
	 */
62
	abstract public function mapRow($model);
63
64
	/** @return mixed[] */
65
	public function getRowValues()
66
	{
67
		return $this->mapRow($this->getModel());
68
	}
69
70
	/** @return string */
71
	public function getTable()
72
	{
73
		return $this->table;
74
	}
75
}
76