Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
14 / 14 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| AbstractFormatter | |
100.00% |
14 / 14 |
|
100.00% |
1 / 1 |
9 | |
100.00% |
1 / 1 |
| unquoteId | |
100.00% |
14 / 14 |
|
100.00% |
1 / 1 |
9 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Pop PHP Framework (https://www.popphp.org/) |
| 4 | * |
| 5 | * @link https://github.com/popphp/popphp-framework |
| 6 | * @author Nick Sagona, III <dev@noladev.com> |
| 7 | * @copyright Copyright (c) 2009-2026 NOLA Interactive, LLC. |
| 8 | * @license https://www.popphp.org/license New BSD License |
| 9 | */ |
| 10 | |
| 11 | /** |
| 12 | * @namespace |
| 13 | */ |
| 14 | namespace Pop\Db\Sql\Schema\Formatter; |
| 15 | |
| 16 | /** |
| 17 | * Schema formatter abstract class |
| 18 | * |
| 19 | * @category Pop |
| 20 | * @package Pop\Db |
| 21 | * @author Nick Sagona, III <dev@noladev.com> |
| 22 | * @copyright Copyright (c) 2009-2026 NOLA Interactive, LLC. |
| 23 | * @license https://www.popphp.org/license New BSD License |
| 24 | * @version 6.7.0 |
| 25 | */ |
| 26 | abstract class AbstractFormatter |
| 27 | { |
| 28 | |
| 29 | /** |
| 30 | * Un-quote identifier |
| 31 | * |
| 32 | * @param string $identifier |
| 33 | * @return string |
| 34 | */ |
| 35 | public static function unquoteId(string $identifier): string |
| 36 | { |
| 37 | if (str_contains($identifier, '.')) { |
| 38 | $identifierAry = explode('.', $identifier); |
| 39 | foreach ($identifierAry as $key => $val) { |
| 40 | $first = substr($val, 0, 1); |
| 41 | if (($first == '`') || ($first == '"') || ($first == '[')) { |
| 42 | $val = substr($val, 1); |
| 43 | $val = substr($val, 0, -1); |
| 44 | } |
| 45 | $identifierAry[$key] = $val; |
| 46 | } |
| 47 | $identifier = implode('.', $identifierAry); |
| 48 | } else { |
| 49 | $first = substr($identifier, 0, 1); |
| 50 | |
| 51 | if (($first == '`') || ($first == '"') || ($first == '[')) { |
| 52 | $identifier = substr($identifier, 1); |
| 53 | $identifier = substr($identifier, 0, -1); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | return $identifier; |
| 58 | } |
| 59 | |
| 60 | } |