Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
11 / 11 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
1 / 1 |
| StringDataType | |
100.00% |
11 / 11 |
|
100.00% |
5 / 5 |
7 | |
100.00% |
1 / 1 |
| charset | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| renderCharset | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
| collate | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| renderCollate | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
| renderTypeAttributes | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php declare(strict_types=1); |
| 2 | /* |
| 3 | * This file is part of Aplus Framework Database Library. |
| 4 | * |
| 5 | * (c) Natan Felles <natanfelles@gmail.com> |
| 6 | * |
| 7 | * For the full copyright and license information, please view the LICENSE |
| 8 | * file that was distributed with this source code. |
| 9 | */ |
| 10 | namespace Framework\Database\Definition\Table\Columns\String; |
| 11 | |
| 12 | use Framework\Database\Definition\Table\Columns\Column; |
| 13 | |
| 14 | /** |
| 15 | * Class StringDataType. |
| 16 | * |
| 17 | * @package database |
| 18 | */ |
| 19 | abstract class StringDataType extends Column |
| 20 | { |
| 21 | protected string $charset; |
| 22 | protected string $collation; |
| 23 | |
| 24 | /** |
| 25 | * @param string $charset |
| 26 | * |
| 27 | * @return static |
| 28 | */ |
| 29 | public function charset(string $charset) : static |
| 30 | { |
| 31 | $this->charset = $charset; |
| 32 | return $this; |
| 33 | } |
| 34 | |
| 35 | protected function renderCharset() : ?string |
| 36 | { |
| 37 | if ( ! isset($this->charset)) { |
| 38 | return null; |
| 39 | } |
| 40 | return ' CHARACTER SET ' . $this->database->quote($this->charset); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * @param string $collation |
| 45 | * |
| 46 | * @return static |
| 47 | */ |
| 48 | public function collate(string $collation) : static |
| 49 | { |
| 50 | $this->collation = $collation; |
| 51 | return $this; |
| 52 | } |
| 53 | |
| 54 | protected function renderCollate() : ?string |
| 55 | { |
| 56 | if ( ! isset($this->collation)) { |
| 57 | return null; |
| 58 | } |
| 59 | return ' COLLATE ' . $this->database->quote($this->collation); |
| 60 | } |
| 61 | |
| 62 | protected function renderTypeAttributes() : ?string |
| 63 | { |
| 64 | return $this->renderCharset() . $this->renderCollate(); |
| 65 | } |
| 66 | } |