summaryrefslogtreecommitdiff
path: root/www/wiki/vendor/param-processor/param-processor/src/PackagePrivate/ParamType.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/vendor/param-processor/param-processor/src/PackagePrivate/ParamType.php')
-rw-r--r--www/wiki/vendor/param-processor/param-processor/src/PackagePrivate/ParamType.php58
1 files changed, 58 insertions, 0 deletions
diff --git a/www/wiki/vendor/param-processor/param-processor/src/PackagePrivate/ParamType.php b/www/wiki/vendor/param-processor/param-processor/src/PackagePrivate/ParamType.php
new file mode 100644
index 00000000..01022a1d
--- /dev/null
+++ b/www/wiki/vendor/param-processor/param-processor/src/PackagePrivate/ParamType.php
@@ -0,0 +1,58 @@
+<?php
+
+namespace ParamProcessor\PackagePrivate;
+
+use ParamProcessor\ParamDefinition;
+use ValueParsers\NullParser;
+use ValueValidators\NullValidator;
+
+/**
+ * Package private
+ */
+class ParamType {
+
+ private $typeId;
+
+ private $className;
+ private $stringParser;
+ private $typedParser;
+ private $validator;
+ private $validationCallback;
+
+ private function __construct( string $typeId ) {
+ $this->typeId = $typeId;
+ }
+
+ public static function newFromArray( string $typeId, array $spec ): self {
+ $type = new self( $typeId );
+
+ $type->className = array_key_exists( 'definition', $spec ) ? $spec['definition'] : ParamDefinition::class;
+ $type->stringParser = array_key_exists( 'string-parser', $spec ) ? $spec['string-parser'] : NullParser::class;
+ $type->typedParser = array_key_exists( 'typed-parser', $spec ) ? $spec['typed-parser'] : NullParser::class;
+ $type->validator = array_key_exists( 'validator', $spec ) ? $spec['validator'] : NullValidator::class;
+ $type->validationCallback = array_key_exists( 'validation-callback', $spec ) ? $spec['validation-callback'] : null;
+
+ return $type;
+ }
+
+ public function getClassName(): string {
+ return $this->className;
+ }
+
+ public function getValidatorClass(): string {
+ return $this->validator;
+ }
+
+ public function getValidationCallback(): ?callable {
+ return $this->validationCallback;
+ }
+
+ public function getStringParserClass(): string {
+ return $this->stringParser;
+ }
+
+ public function getTypedParserClass(): string {
+ return $this->typedParser;
+ }
+
+}