-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRowOperation.php
More file actions
85 lines (65 loc) · 1.83 KB
/
RowOperation.php
File metadata and controls
85 lines (65 loc) · 1.83 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
<?php
declare(strict_types=1);
/*
* This file is part of the QuidPHP package <https://quidphp.com>
* Author: Pierre-Philippe Emond <emondpph@gmail.com>
* License: https://github.com/quidphp/orm/blob/master/LICENSE
*/
namespace Quid\Orm;
// rowOperation
// abstract class used for a complex operation on a table row
abstract class RowOperation extends Operation
{
// config
protected static array $config = [];
// dynamique
protected Row $row; // conserve la row pour l'opération
// construct
// construit l'objet de l'opération
final public function __construct(Row $row,?array $attr=null)
{
$this->makeAttr($attr);
$this->setRow($row);
}
// isValidTimestamp
// retourne vrai si le timestamp fourni est plus récent que le dernier dateCommit
// utilise valueInitial car le timestamp peut avoir changé dans les include
final public function isValidTimestamp(int $value):bool
{
$row = $this->row();
$commit = $row->newestDateCommit();
$initial = (!empty($commit))? $commit['date']->valueInitial():null;
return empty($initial) || $initial <= $value;
}
// setRow
// lie une row à l'objet
final protected function setRow(Row $row):void
{
$this->row = $row;
}
// row
// retourne la row lié à l'opération
final protected function row():Row
{
return $this->row;
}
// cells
// retourne l'objet cells de la row
final protected function cells():Cells
{
return $this->row()->cells();
}
// table
// retourne l'objet table de la row
final protected function table():Table
{
return $this->row()->table();
}
// db
// retourne la db de l'opération
final public function db():Db
{
return $this->row()->db();
}
}
?>