12
12
*/
13
13
abstract class Repository
14
14
{
15
+ /** @var Connection */
15
16
private $ connection ;
16
17
17
18
public function __construct (Connection $ connection )
@@ -45,12 +46,22 @@ protected function findOne(Schema $schema, array $conditions): ?Model
45
46
return $ row ? $ schema ->createModelFromRow ($ row ) : null ;
46
47
}
47
48
49
+ /**
50
+ * @param Schema $schema
51
+ * @param mixed $values
52
+ * @return null|Model
53
+ */
48
54
protected function findByPrimaryKey (Schema $ schema , $ values ): ?Model
49
55
{
50
56
return $ this ->findOne ($ schema , $ this ->getPrimaryKeyCondition ($ schema , $ values ));
51
57
}
52
58
53
- protected function getPrimaryKeyCondition (Schema $ schema , $ values )
59
+ /**
60
+ * @param Schema $schema
61
+ * @param mixed $values
62
+ * @return array
63
+ */
64
+ protected function getPrimaryKeyCondition (Schema $ schema , $ values ): array
54
65
{
55
66
$ keys = $ schema ->getPrimaryKey ();
56
67
$ condition = [];
@@ -94,7 +105,7 @@ protected function save(Model $model): void
94
105
$ this ->update ($ model );
95
106
}
96
107
97
- protected function insert (Model $ model )
108
+ protected function insert (Model $ model ): void
98
109
{
99
110
$ record = $ model ->getDatabaseRecord ();
100
111
$ schema = $ record ->getSchema ();
@@ -119,7 +130,7 @@ protected function insert(Model $model)
119
130
$ record ->updateState (Record::STATE_INSERT );
120
131
}
121
132
122
- protected function update (Model $ model )
133
+ protected function update (Model $ model ): void
123
134
{
124
135
$ record = $ model ->getDatabaseRecord ();
125
136
$ schema = $ record ->getSchema ();
@@ -129,7 +140,7 @@ protected function update(Model $model)
129
140
$ record ->updateState (Record::STATE_UPDATE );
130
141
}
131
142
132
- protected function delete (Model $ model )
143
+ protected function delete (Model $ model ): void
133
144
{
134
145
$ record = $ model ->getDatabaseRecord ();
135
146
$ schema = $ record ->getSchema ();
0 commit comments