Base.php
3 months ago
BaseColumnFactory.php
3 months ago
ColumnFactory.php
3 months ago
ColumnIdGenerator.php
3 months ago
ColumnLabelTrait.php
3 months ago
Context.php
3 months ago
CustomFieldContext.php
3 months ago
GroupTrait.php
3 months ago
LabelEncoder.php
3 months ago
SettingUpdater.php
3 months ago
ColumnIdGenerator.php
30 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Column; |
| 6 | |
| 7 | use AC\Setting\Config; |
| 8 | use AC\Type\ColumnId; |
| 9 | use AC\Type\KeyGenerator; |
| 10 | |
| 11 | final class ColumnIdGenerator extends KeyGenerator |
| 12 | { |
| 13 | |
| 14 | public function from_config(Config $config): ColumnId |
| 15 | { |
| 16 | $id = (string)$config->get('name'); |
| 17 | |
| 18 | if (ColumnId::is_valid_id($id)) { |
| 19 | return new ColumnId($id); |
| 20 | } |
| 21 | |
| 22 | return $this->generate(); |
| 23 | } |
| 24 | |
| 25 | public function generate(): ColumnId |
| 26 | { |
| 27 | return new ColumnId($this->generate_raw()); |
| 28 | } |
| 29 | |
| 30 | } |