1 | <?php |
||
5 | abstract class Column implements DatabaseObjectInterface |
||
6 | { |
||
7 | protected $name; |
||
8 | protected $description; |
||
9 | protected $isNotNull = false; |
||
10 | protected $default; |
||
11 | |||
12 | /** |
||
13 | * Constructor. |
||
14 | * |
||
15 | * @param string $name Column name. |
||
16 | * @param array $options Optional options. |
||
17 | */ |
||
18 | public function __construct($name, array $options = array()) |
||
29 | |||
30 | /** |
||
31 | * Get column name. |
||
32 | * |
||
33 | * @return string Column name. |
||
34 | */ |
||
35 | public function getName() |
||
39 | |||
40 | /** |
||
41 | * Get default value of column. |
||
42 | * |
||
43 | * @return mixed Default value of column. |
||
44 | */ |
||
45 | public function getDefault() |
||
49 | |||
50 | /** |
||
51 | * Check if column not allows null value. |
||
52 | * |
||
53 | * @return boolean Column not allows null value. |
||
54 | */ |
||
55 | public function isNotNull() |
||
59 | |||
60 | /** |
||
61 | * Set the table instance. |
||
62 | * |
||
63 | * @param Table $table Table instance. |
||
64 | * |
||
65 | * @return void |
||
66 | */ |
||
67 | public function setTable(Table $table) |
||
71 | |||
72 | /** |
||
73 | * Get the table instance. |
||
74 | * |
||
75 | * @return Table |
||
76 | */ |
||
77 | public function getTable() |
||
81 | |||
82 | /** |
||
83 | * Get column type name. |
||
84 | * |
||
85 | * @return string Column type name. |
||
86 | */ |
||
87 | abstract public function getType(); |
||
88 | |||
89 | /** |
||
90 | * Set column description. |
||
91 | * |
||
92 | * @param string $description Table description. |
||
93 | */ |
||
94 | public function setDescription($description) |
||
98 | |||
99 | /** |
||
100 | * Get column description. |
||
101 | * |
||
102 | * @return string |
||
103 | */ |
||
104 | public function getDescription() |
||
108 | } |
||
109 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: