@@ -15,7 +15,7 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class InvalidValueException extends InvalidArgumentException implements ExceptionInterface |
| 17 | 17 | { |
| 18 | - public function __construct($value, $class) |
|
| 18 | + public function __construct ($value, $class) |
|
| 19 | 19 | { |
| 20 | 20 | $message = sprintf('%s is not an acceptable value for "%s" enum.', json_encode($value), $class); |
| 21 | 21 | |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @param mixed $value The raw value of an enumeration |
| 34 | 34 | */ |
| 35 | - private function __construct($value) |
|
| 35 | + private function __construct ($value) |
|
| 36 | 36 | { |
| 37 | 37 | $this->value = $value; |
| 38 | 38 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @return static The enum instance for given value |
| 59 | 59 | */ |
| 60 | - public static function create($value): EnumInterface |
|
| 60 | + public static function create ($value): EnumInterface |
|
| 61 | 61 | { |
| 62 | 62 | $enumType = static::class; |
| 63 | 63 | $identifier = serialize($value); |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * |
| 85 | 85 | * @return static When $name is an existing constant for this enumeration type |
| 86 | 86 | */ |
| 87 | - public static function __callStatic($name, $arguments = []): EnumInterface |
|
| 87 | + public static function __callStatic ($name, $arguments = []): EnumInterface |
|
| 88 | 88 | { |
| 89 | 89 | $value = @constant('static::' . $name); |
| 90 | 90 | if (null === $value) { |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | /** |
| 102 | 102 | * {@inheritdoc} |
| 103 | 103 | */ |
| 104 | - public static function accepts($value): bool |
|
| 104 | + public static function accepts ($value): bool |
|
| 105 | 105 | { |
| 106 | 106 | return in_array($value, static::values(), true); |
| 107 | 107 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | /** |
| 110 | 110 | * {@inheritdoc} |
| 111 | 111 | */ |
| 112 | - public static function instances(): array |
|
| 112 | + public static function instances (): array |
|
| 113 | 113 | { |
| 114 | 114 | return array_map(function ($value) { |
| 115 | 115 | return static::create($value); |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | /** |
| 120 | 120 | * {@inheritdoc} |
| 121 | 121 | */ |
| 122 | - public function getValue() |
|
| 122 | + public function getValue () |
|
| 123 | 123 | { |
| 124 | 124 | return $this->value; |
| 125 | 125 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | /** |
| 128 | 128 | * {@inheritdoc} |
| 129 | 129 | */ |
| 130 | - public function equals(EnumInterface $enum): bool |
|
| 130 | + public function equals (EnumInterface $enum): bool |
|
| 131 | 131 | { |
| 132 | 132 | return get_class($this) === get_class($enum) && $this->value === $enum->getValue(); |
| 133 | 133 | } |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | /** |
| 136 | 136 | * {@inheritdoc} |
| 137 | 137 | */ |
| 138 | - public function is($value): bool |
|
| 138 | + public function is ($value): bool |
|
| 139 | 139 | { |
| 140 | 140 | return $this->getValue() === $value; |
| 141 | 141 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * {@inheritdoc} |
| 19 | 19 | */ |
| 20 | - public static function readableFor($value): string |
|
| 20 | + public static function readableFor ($value): string |
|
| 21 | 21 | { |
| 22 | 22 | if (!static::accepts($value)) { |
| 23 | 23 | throw new InvalidValueException($value, static::class); |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | /** |
| 31 | 31 | * {@inheritdoc} |
| 32 | 32 | */ |
| 33 | - public function getReadable(): string |
|
| 33 | + public function getReadable (): string |
|
| 34 | 34 | { |
| 35 | 35 | return static::readableFor($this->getValue()); |
| 36 | 36 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | /** |
| 39 | 39 | * {@inheritdoc} |
| 40 | 40 | */ |
| 41 | - public function __toString() |
|
| 41 | + public function __toString () |
|
| 42 | 42 | { |
| 43 | 43 | return (string) $this->getReadable(); |
| 44 | 44 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @param EnumInterface $object |
| 25 | 25 | */ |
| 26 | - public function normalize($object, $format = null, array $context = []) |
|
| 26 | + public function normalize ($object, $format = null, array $context = []) |
|
| 27 | 27 | { |
| 28 | 28 | return $object->getValue(); |
| 29 | 29 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | /** |
| 32 | 32 | * {@inheritdoc} |
| 33 | 33 | */ |
| 34 | - public function supportsNormalization($data, $format = null) |
|
| 34 | + public function supportsNormalization ($data, $format = null) |
|
| 35 | 35 | { |
| 36 | 36 | return $data instanceof EnumInterface; |
| 37 | 37 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | /** |
| 40 | 40 | * {@inheritdoc} |
| 41 | 41 | */ |
| 42 | - public function denormalize($data, $class, $format = null, array $context = []) |
|
| 42 | + public function denormalize ($data, $class, $format = null, array $context = []) |
|
| 43 | 43 | { |
| 44 | 44 | try { |
| 45 | 45 | return call_user_func([$class, 'create'], $data); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | /** |
| 52 | 52 | * {@inheritdoc} |
| 53 | 53 | */ |
| 54 | - public function supportsDenormalization($data, $type, $format = null) |
|
| 54 | + public function supportsDenormalization ($data, $type, $format = null) |
|
| 55 | 55 | { |
| 56 | 56 | return is_a($type, EnumInterface::class, true); |
| 57 | 57 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @return FlaggedEnum[]|null An array of FlaggedEnum instances with single bit flag |
| 26 | 26 | */ |
| 27 | - public function transform($value) |
|
| 27 | + public function transform ($value) |
|
| 28 | 28 | { |
| 29 | 29 | if ($value === null) { |
| 30 | 30 | return null; |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @return FlaggedEnum|null A single FlaggedEnum instance or null |
| 54 | 54 | */ |
| 55 | - public function reverseTransform($values) |
|
| 55 | + public function reverseTransform ($values) |
|
| 56 | 56 | { |
| 57 | 57 | if (null === $values) { |
| 58 | 58 | return null; |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * @return int[]|null An array of bit flags |
| 26 | 26 | */ |
| 27 | - public function transform($bitmask) |
|
| 27 | + public function transform ($bitmask) |
|
| 28 | 28 | { |
| 29 | 29 | if ($bitmask === null) { |
| 30 | 30 | return null; |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @return int|null a bit mask |
| 59 | 59 | */ |
| 60 | - public function reverseTransform($flags) |
|
| 60 | + public function reverseTransform ($flags) |
|
| 61 | 61 | { |
| 62 | 62 | if (null === $flags) { |
| 63 | 63 | return null; |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | /** @var string|FlaggedEnum */ |
| 20 | 20 | protected $enumClass; |
| 21 | 21 | |
| 22 | - public function __construct(string $enumClass) |
|
| 22 | + public function __construct (string $enumClass) |
|
| 23 | 23 | { |
| 24 | 24 | if (!is_a($enumClass, FlaggedEnum::class, true)) { |
| 25 | 25 | throw new InvalidArgumentException(sprintf( |
@@ -32,12 +32,12 @@ discard block |
||
| 32 | 32 | $this->enumClass = $enumClass; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - protected function createEnum(int $value): FlaggedEnum |
|
| 35 | + protected function createEnum (int $value): FlaggedEnum |
|
| 36 | 36 | { |
| 37 | 37 | return call_user_func([$this->enumClass, 'create'], $value); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - protected function isAcceptableValueForEnum(int $value): bool |
|
| 40 | + protected function isAcceptableValueForEnum (int $value): bool |
|
| 41 | 41 | { |
| 42 | 42 | return call_user_func([$this->enumClass, 'accepts'], $value); |
| 43 | 43 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | class FlaggedEnumType extends AbstractType |
| 22 | 22 | { |
| 23 | - public function buildForm(FormBuilderInterface $builder, array $options) |
|
| 23 | + public function buildForm (FormBuilderInterface $builder, array $options) |
|
| 24 | 24 | { |
| 25 | 25 | if (!$options['multiple']) { |
| 26 | 26 | throw new InvalidConfigurationException(sprintf( |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | /** |
| 41 | 41 | * {@inheritdoc} |
| 42 | 42 | */ |
| 43 | - public function configureOptions(OptionsResolver $resolver) |
|
| 43 | + public function configureOptions (OptionsResolver $resolver) |
|
| 44 | 44 | { |
| 45 | 45 | $resolver |
| 46 | 46 | ->setDefault('multiple', true) |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | /** |
| 54 | 54 | * {@inheritdoc} |
| 55 | 55 | */ |
| 56 | - public function getParent() |
|
| 56 | + public function getParent () |
|
| 57 | 57 | { |
| 58 | 58 | return EnumType::class; |
| 59 | 59 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | /** |
| 23 | 23 | * {@inheritdoc} |
| 24 | 24 | */ |
| 25 | - public function configureOptions(OptionsResolver $resolver) |
|
| 25 | + public function configureOptions (OptionsResolver $resolver) |
|
| 26 | 26 | { |
| 27 | 27 | $resolver |
| 28 | 28 | ->setDefaults([ |
@@ -69,12 +69,12 @@ discard block |
||
| 69 | 69 | /** |
| 70 | 70 | * {@inheritdoc} |
| 71 | 71 | */ |
| 72 | - public function getParent() |
|
| 72 | + public function getParent () |
|
| 73 | 73 | { |
| 74 | 74 | return ChoiceType::class; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - private function isReadable(string $enumClass) |
|
| 77 | + private function isReadable (string $enumClass) |
|
| 78 | 78 | { |
| 79 | 79 | return is_a($enumClass, ReadableEnumInterface::class, true); |
| 80 | 80 | } |