| Total Complexity | 9 |
| Total Lines | 90 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 5 | trait Escaping |
||
| 6 | { |
||
| 7 | /** @var string */ |
||
| 8 | protected $quotingCharacter = '"'; |
||
| 9 | /** @var string */ |
||
| 10 | protected $identifierDivider = '.'; |
||
| 11 | /** @var string */ |
||
| 12 | protected $booleanTrue = '1'; |
||
| 13 | /** @var string */ |
||
| 14 | protected $booleanFalse = '0'; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Extract content from parenthesis in $type |
||
| 18 | * |
||
| 19 | * @param string $type |
||
| 20 | * @return string |
||
| 21 | */ |
||
| 22 | protected function extractParenthesis($type) |
||
| 23 | { |
||
| 24 | if (preg_match('/\((.+)\)/', $type, $match)) { |
||
| 25 | return $match[1]; |
||
| 26 | } |
||
| 27 | |||
| 28 | return null; |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Escape a string for query |
||
| 33 | * |
||
| 34 | * @param string $value |
||
| 35 | * @return string |
||
| 36 | */ |
||
| 37 | protected function escapeString($value) |
||
| 38 | { |
||
| 39 | return $this->entityManager->getConnection()->quote($value); |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Escape an integer for query |
||
| 44 | * |
||
| 45 | * @param int $value |
||
| 46 | * @return string |
||
| 47 | */ |
||
| 48 | protected function escapeInteger($value) |
||
| 49 | { |
||
| 50 | return (string) $value; |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Escape a double for Query |
||
| 55 | * |
||
| 56 | * @param double $value |
||
| 57 | * @return string |
||
| 58 | */ |
||
| 59 | protected function escapeDouble($value) |
||
| 60 | { |
||
| 61 | return (string) $value; |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Escape NULL for query |
||
| 66 | * |
||
| 67 | * @return string |
||
| 68 | */ |
||
| 69 | protected function escapeNULL() |
||
| 70 | { |
||
| 71 | return 'NULL'; |
||
| 72 | } |
||
| 73 | |||
| 74 | /** |
||
| 75 | * Escape a boolean for query |
||
| 76 | * |
||
| 77 | * @param bool $value |
||
| 78 | * @return string |
||
| 79 | */ |
||
| 80 | protected function escapeBoolean($value) |
||
| 81 | { |
||
| 82 | return ($value) ? $this->booleanTrue : $this->booleanFalse; |
||
| 83 | } |
||
| 84 | |||
| 85 | /** |
||
| 86 | * Escape a date time object for query |
||
| 87 | * |
||
| 88 | * @param \DateTime $value |
||
| 89 | * @return mixed |
||
| 90 | */ |
||
| 91 | protected function escapeDateTime(\DateTime $value) |
||
| 95 | } |
||
| 96 | } |
||
| 97 |