| 1 | <?php |
||
| 8 | trait Escaping |
||
| 9 | { |
||
| 10 | /** @var string */ |
||
| 11 | protected $quotingCharacter = '"'; |
||
| 12 | /** @var string */ |
||
| 13 | protected $identifierDivider = '.'; |
||
| 14 | /** @var string */ |
||
| 15 | protected $booleanTrue = '1'; |
||
| 16 | /** @var string */ |
||
| 17 | protected $booleanFalse = '0'; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Extract content from parenthesis in $type |
||
| 21 | * |
||
| 22 | * @param string $type |
||
| 23 | * @return string |
||
| 24 | */ |
||
| 25 | protected function extractParenthesis($type) |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Escape a string for query |
||
| 36 | * |
||
| 37 | * @param string $value |
||
| 38 | * @return string |
||
| 39 | */ |
||
| 40 | protected function escapeString($value) |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Escape an integer for query |
||
| 47 | * |
||
| 48 | * @param int $value |
||
| 49 | * @return string |
||
| 50 | */ |
||
| 51 | protected function escapeInteger($value) |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Escape a double for Query |
||
| 58 | * |
||
| 59 | * @param double $value |
||
| 60 | * @return string |
||
| 61 | */ |
||
| 62 | protected function escapeDouble($value) |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Escape NULL for query |
||
| 69 | * |
||
| 70 | * @return string |
||
| 71 | */ |
||
| 72 | protected function escapeNULL() |
||
| 76 | |||
| 77 | /** |
||
| 78 | * Escape a boolean for query |
||
| 79 | * |
||
| 80 | * @param bool $value |
||
| 81 | * @return string |
||
| 82 | */ |
||
| 83 | protected function escapeBoolean($value) |
||
| 87 | |||
| 88 | /** |
||
| 89 | * Escape a date time object for query |
||
| 90 | * |
||
| 91 | * @param DateTime $value |
||
| 92 | * @return mixed |
||
| 93 | */ |
||
| 94 | protected function escapeDateTime(DateTime $value) |
||
| 99 | } |
||
| 100 |
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: