| @@ 12-32 (lines=21) @@ | ||
| 9 | /** |
|
| 10 | * @SuppressWarnings(PHPMD.NumberOfChildren) |
|
| 11 | */ |
|
| 12 | abstract class AbstractType implements TypeInterface |
|
| 13 | { |
|
| 14 | /** |
|
| 15 | * @var AbstractType[] |
|
| 16 | */ |
|
| 17 | protected static $registry = []; |
|
| 18 | ||
| 19 | public function getFriendlyId(): string |
|
| 20 | { |
|
| 21 | return $this->getId(); |
|
| 22 | } |
|
| 23 | ||
| 24 | public static function getInstance() |
|
| 25 | { |
|
| 26 | $class = get_called_class(); |
|
| 27 | if (!isset(self::$registry[$class])) { |
|
| 28 | self::$registry[$class] = new static(); |
|
| 29 | } |
|
| 30 | return self::$registry[$class]; |
|
| 31 | } |
|
| 32 | } |
|
| 33 | ||
| @@ 9-37 (lines=29) @@ | ||
| 6 | ||
| 7 | use AmaTeam\ElasticSearch\API\Mapping\Type\ParameterInterface; |
|
| 8 | ||
| 9 | abstract class AbstractParameter implements ParameterInterface |
|
| 10 | { |
|
| 11 | /** |
|
| 12 | * @var AbstractParameter[] |
|
| 13 | */ |
|
| 14 | protected static $registry = []; |
|
| 15 | ||
| 16 | public function getFriendlyId(): string |
|
| 17 | { |
|
| 18 | return $this->getId(); |
|
| 19 | } |
|
| 20 | ||
| 21 | /** |
|
| 22 | * @inheritDoc |
|
| 23 | */ |
|
| 24 | public function nullValueAllowed(): bool |
|
| 25 | { |
|
| 26 | return false; |
|
| 27 | } |
|
| 28 | ||
| 29 | public static function getInstance() |
|
| 30 | { |
|
| 31 | $className = get_called_class(); |
|
| 32 | if (!isset(static::$registry[$className])) { |
|
| 33 | static::$registry[$className] = new static(); |
|
| 34 | } |
|
| 35 | return static::$registry[$className]; |
|
| 36 | } |
|
| 37 | } |
|
| 38 | ||