diff --git a/api.php b/api.php new file mode 100644 index 0000000..8a0aed6 --- /dev/null +++ b/api.php @@ -0,0 +1,34 @@ +value()) { + echo '1'; +} + +if (true === $Parameter->isValid()) { + echo '2'; +} + +$Parameters = new Parameters(['name' => 'pierre', 'phone', '0648099915']); + +true === $Parameters->isValid(); +//[...] === $Parameters->values(); + +} diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..e69de29 diff --git a/src/Checker/Scalar.php b/src/Checker/Scalar.php new file mode 100644 index 0000000..7025341 --- /dev/null +++ b/src/Checker/Scalar.php @@ -0,0 +1,16 @@ +key = $key; + $this->value = $value; + } + + public function isValid() + { + $checker = $this->mapAssertion($this->key); + + if (null === $checker) { + //TODO assertion missing for this parameter + } + } + + public function value() + { + $conveter = $this->mapConverter($this->key); + + if (null === $converter) { + return $this->value; + } + + //TODO call converter + } +} diff --git a/src/Parameters.php b/src/Parameters.php new file mode 100644 index 0000000..411eeed --- /dev/null +++ b/src/Parameters.php @@ -0,0 +1,40 @@ + $value) { + + if ($value instanceof Parameter) { + $this->iterator = $value; + continue; + } + + $this->iterator[] = new Parameter($key, $value); + } + } + + public function isValid() + { + foreach ($this->iterator as $parameter) { + //TODO we dont need stop if we want group hoa exception + } + } + + public function values() + { + $result = []; + + foreach ($this->iterator as $parameter) { + $result[$parameter->key()] = $parameter->value(); + } + + return $result; + } +}