1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Soluble\Datatype\Column\Definition; |
4
|
|
|
|
5
|
|
|
class DecimalColumn extends AbstractColumnDefinition implements NumericColumnInterface |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* @var int |
9
|
|
|
*/ |
10
|
|
|
protected $numericPrecision = null; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @var int |
14
|
|
|
*/ |
15
|
|
|
protected $numericScale = null; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var bool |
19
|
|
|
*/ |
20
|
|
|
protected $numericUnsigned = null; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @return bool |
24
|
|
|
*/ |
25
|
|
|
public function getNumericUnsigned() |
26
|
|
|
{ |
27
|
|
|
return $this->numericUnsigned; |
28
|
|
|
} |
29
|
|
|
|
30
|
1 |
|
/** |
31
|
|
|
* @param bool $numericUnsigned |
32
|
1 |
|
* |
33
|
|
|
* @return DecimalColumn |
34
|
|
|
*/ |
35
|
|
|
public function setNumericUnsigned($numericUnsigned) |
36
|
|
|
{ |
37
|
|
|
$this->numericUnsigned = $numericUnsigned; |
38
|
|
|
|
39
|
1 |
|
return $this; |
40
|
|
|
} |
41
|
1 |
|
|
42
|
1 |
|
/** |
43
|
|
|
* @return bool |
44
|
|
|
*/ |
45
|
|
|
public function isNumericUnsigned() |
46
|
|
|
{ |
47
|
|
|
return $this->numericUnsigned; |
48
|
|
|
} |
49
|
1 |
|
|
50
|
|
|
/** |
51
|
1 |
|
* Return the precision, for example |
52
|
|
|
* salary DECIMAL(5,2) |
53
|
|
|
* In this example, 5 is the precision and 2 is the scale. |
54
|
|
|
* Standard SQL requires that DECIMAL(5,2) be able to store any value |
55
|
|
|
* with five digits and two decimals, so values that can be stored in |
56
|
|
|
* the salary column range from -999.99 to 999.99. |
57
|
|
|
* |
58
|
|
|
* @return int the $numericPrecision |
59
|
|
|
*/ |
60
|
|
|
public function getNumericPrecision() |
61
|
|
|
{ |
62
|
|
|
return $this->numericPrecision; |
63
|
|
|
} |
64
|
1 |
|
|
65
|
|
|
/** |
66
|
1 |
|
* @param int $numericPrecision the $numericPrevision to set |
67
|
|
|
* |
68
|
|
|
* @return DecimalColumn |
69
|
|
|
*/ |
70
|
|
|
public function setNumericPrecision($numericPrecision) |
71
|
|
|
{ |
72
|
|
|
$this->numericPrecision = $numericPrecision; |
73
|
1 |
|
|
74
|
|
|
return $this; |
75
|
1 |
|
} |
76
|
1 |
|
|
77
|
|
|
/** |
78
|
|
|
* Return the scale (number of decimal digits) |
79
|
|
|
* salary DECIMAL(5,2) |
80
|
|
|
* In this example, 5 is the precision and 2 is the scale. |
81
|
|
|
* Standard SQL requires that DECIMAL(5,2) be able to store any value |
82
|
|
|
* with five digits and two decimals, so values that can be stored in |
83
|
|
|
* the salary column range from -999.99 to 999.99. |
84
|
|
|
* |
85
|
|
|
* @return int the $numericScale |
86
|
|
|
*/ |
87
|
|
|
public function getNumericScale() |
88
|
|
|
{ |
89
|
1 |
|
return $this->numericScale; |
90
|
|
|
} |
91
|
1 |
|
|
92
|
|
|
/** |
93
|
|
|
* @param int $numericScale the $numericScale to set |
94
|
|
|
* |
95
|
|
|
* @return DecimalColumn |
96
|
|
|
*/ |
97
|
|
|
public function setNumericScale($numericScale) |
98
|
1 |
|
{ |
99
|
|
|
$this->numericScale = $numericScale; |
100
|
1 |
|
|
101
|
1 |
|
return $this; |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|