-
Notifications
You must be signed in to change notification settings - Fork 0
/
Primary.php
75 lines (58 loc) · 1.68 KB
/
Primary.php
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
<?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/core/blob/master/LICENSE
*/
namespace Quid\Core\Cell;
use Quid\Core;
use Quid\Orm;
// primary
// class for dealing with a cell of a column which has an auto increment primary key
class Primary extends Core\CellAlias
{
// config
protected static array $config = [];
// set
// set pour cell primaire n'est pas permis
// aucune erreur envoyé si le id est le même qu'initial
final public function set($value,?array $option=null):Orm\Cell
{
if(!(is_int($value) && !empty($this->value['initial']) && $this->value['initial'] === $value))
static::throw();
return $this;
}
// setInitial
// setInitial pour cell primaire est seulement permis si:
// il n'y pas de valeur initial ou si la valeur donné est la valeur initial
// onInit n'est pas appelé
final public function setInitial($value):Orm\Cell
{
if(is_int($value) && (empty($this->value['initial']) || $this->value['initial'] === $value))
{
if(empty($this->value['initial']))
$this->value['initial'] = $value;
}
else
static::throw();
return $this;
}
// reset
// reset pour cell primaire n'est pas permis
final public function reset():Orm\Cell
{
static::throw();
return $this;
}
// unset
// unset pour cell primaire n'est pas permis
final public function unset():Orm\Cell
{
static::throw();
return $this;
}
}
// init
Primary::__init();
?>