| 1 | <?php |
||
| 14 | class Constrant |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * constrants do banco de dados |
||
| 18 | * -foreingkey |
||
| 19 | * -primarykey |
||
| 20 | * -unique |
||
| 21 | * |
||
| 22 | * @author Pedro Alarcao <[email protected]> |
||
| 23 | */ |
||
| 24 | final private function __construct () |
||
| 27 | |||
| 28 | public static function getInstance () |
||
| 29 | { |
||
| 30 | return new self(); |
||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @var string |
||
| 35 | */ |
||
| 36 | protected $constrant; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @var string |
||
| 40 | */ |
||
| 41 | protected $schema; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @var string |
||
| 45 | */ |
||
| 46 | protected $table; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @var string |
||
| 50 | */ |
||
| 51 | protected $column; |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @param $array |
||
| 55 | * |
||
| 56 | * @return Constrant |
||
| 57 | */ |
||
| 58 | public function populate ( $array ) |
||
| 59 | { |
||
| 60 | if ( isset( $array[ 'schema' ] ) ) |
||
| 61 | { |
||
| 62 | $this->schema = $array[ 'schema' ]; |
||
| 63 | } |
||
| 64 | |||
| 65 | $this->database = $array[ 'database' ]; |
||
|
|
|||
| 66 | $this->constrant = $array[ 'constrant' ]; |
||
| 67 | $this->table = $array[ 'table' ]; |
||
| 68 | $this->column = $array[ 'column' ]; |
||
| 69 | |||
| 70 | return $this; |
||
| 71 | } |
||
| 72 | |||
| 73 | public function getDatabase (){ |
||
| 74 | return $this->database; |
||
| 75 | } |
||
| 76 | |||
| 77 | /** |
||
| 78 | * @return string |
||
| 79 | */ |
||
| 80 | public function getNameConstrant () |
||
| 84 | |||
| 85 | public function hasSchema () |
||
| 89 | |||
| 90 | /** |
||
| 91 | * @return string |
||
| 92 | */ |
||
| 93 | public function getSchema () |
||
| 97 | |||
| 98 | /** |
||
| 99 | * @return string |
||
| 100 | */ |
||
| 101 | public function getTable () |
||
| 105 | |||
| 106 | /** |
||
| 107 | * @return string |
||
| 108 | */ |
||
| 109 | public function getColumn () |
||
| 113 | |||
| 114 | } |
||
| 115 |
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: