@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * @param ApplicationContracts $app |
| 24 | 24 | * @param $request |
| 25 | 25 | */ |
| 26 | - public function __construct(ApplicationContracts $app,$request) |
|
| 26 | + public function __construct(ApplicationContracts $app, $request) |
|
| 27 | 27 | {
|
| 28 | 28 | parent::__construct($app); |
| 29 | 29 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @throws \ReflectionException |
| 42 | 42 | */ |
| 43 | - public function annotation($method,$key) |
|
| 43 | + public function annotation($method, $key) |
|
| 44 | 44 | {
|
| 45 | 45 | //set annotation value with getting reflection |
| 46 | 46 | $reflection = $this->getReflection('reflection')->reflectionMethodParams($method);
|
@@ -62,13 +62,13 @@ discard block |
||
| 62 | 62 | * @param $key |
| 63 | 63 | * @param $data |
| 64 | 64 | */ |
| 65 | - private function catchException($key,$data) |
|
| 65 | + private function catchException($key, $data) |
|
| 66 | 66 | {
|
| 67 | - if(isset($this->exceptionParams[$key])){
|
|
| 67 | + if (isset($this->exceptionParams[$key])) {
|
|
| 68 | 68 | $keyParams = ($this->exceptionParams[$key]['params']) ?? []; |
| 69 | - exception($this->exceptionParams[$key]['name'],$keyParams)->unexpectedValue($key.' input value is not valid as format ('.$data.')');
|
|
| 69 | + exception($this->exceptionParams[$key]['name'], $keyParams)->unexpectedValue($key.' input value is not valid as format ('.$data.')');
|
|
| 70 | 70 | } |
| 71 | - else{
|
|
| 71 | + else {
|
|
| 72 | 72 | exception()->unexpectedValue($key.' input value is not valid as format ('.$data.')');
|
| 73 | 73 | } |
| 74 | 74 | } |
@@ -81,20 +81,20 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | private function getException($key) |
| 83 | 83 | {
|
| 84 | - if(preg_match('@exception\((.*?)\)\r\n@is',$this->annotation,$exception)){
|
|
| 84 | + if (preg_match('@exception\((.*?)\)\r\n@is', $this->annotation, $exception)) {
|
|
| 85 | 85 | |
| 86 | - $exceptionSpaceExplode = explode(" ",$exception[1]);
|
|
| 87 | - foreach ($exceptionSpaceExplode as $exceptions){
|
|
| 88 | - $exceptionsDotExplode = explode(":",$exceptions);
|
|
| 86 | + $exceptionSpaceExplode = explode(" ", $exception[1]);
|
|
| 87 | + foreach ($exceptionSpaceExplode as $exceptions) {
|
|
| 88 | + $exceptionsDotExplode = explode(":", $exceptions);
|
|
| 89 | 89 | $this->exceptionParams[$key][$exceptionsDotExplode[0]] = $exceptionsDotExplode[1]; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - if(isset($this->exceptionParams[$key]['params'])){
|
|
| 93 | - $paramsCommaExplode = explode(",",$this->exceptionParams[$key]['params']);
|
|
| 92 | + if (isset($this->exceptionParams[$key]['params'])) {
|
|
| 93 | + $paramsCommaExplode = explode(",", $this->exceptionParams[$key]['params']);
|
|
| 94 | 94 | unset($this->exceptionParams[$key]['params']); |
| 95 | - foreach ($paramsCommaExplode as $params){
|
|
| 96 | - $paramsEqualExplode = explode("=",$params);
|
|
| 97 | - if(isset($paramsEqualExplode[0]) && isset($paramsEqualExplode[1])){
|
|
| 95 | + foreach ($paramsCommaExplode as $params) {
|
|
| 96 | + $paramsEqualExplode = explode("=", $params);
|
|
| 97 | + if (isset($paramsEqualExplode[0]) && isset($paramsEqualExplode[1])) {
|
|
| 98 | 98 | $this->exceptionParams[$key]['params'][$paramsEqualExplode[0]] = $paramsEqualExplode[1]; |
| 99 | 99 | } |
| 100 | 100 | } |
@@ -111,24 +111,24 @@ discard block |
||
| 111 | 111 | {
|
| 112 | 112 | // with the method based regex annotation, |
| 113 | 113 | // we check the rule definition for our requests. |
| 114 | - if(preg_match('@regex\((.*?)\)\r\n@is',$this->annotation,$regex)){
|
|
| 115 | - if(isset($this->inputs[$key])){
|
|
| 114 | + if (preg_match('@regex\((.*?)\)\r\n@is', $this->annotation, $regex)) {
|
|
| 115 | + if (isset($this->inputs[$key])) {
|
|
| 116 | 116 | |
| 117 | 117 | // for the definition of rules, |
| 118 | 118 | // our inputs can be array and in this case we offer array option for user comfort. |
| 119 | - if(is_array($this->inputs[$key])){
|
|
| 119 | + if (is_array($this->inputs[$key])) {
|
|
| 120 | 120 | |
| 121 | - foreach ($this->inputs[$key] as $this->inputsKey=>$this->inputsValue){
|
|
| 122 | - if(!preg_match('@'.$regex[1].'@is',$this->inputsValue)){
|
|
| 123 | - $this->catchException($key,$regex[1]); |
|
| 121 | + foreach ($this->inputs[$key] as $this->inputsKey=>$this->inputsValue) {
|
|
| 122 | + if (!preg_match('@'.$regex[1].'@is', $this->inputsValue)) {
|
|
| 123 | + $this->catchException($key, $regex[1]); |
|
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | } |
| 127 | - else{
|
|
| 127 | + else {
|
|
| 128 | 128 | |
| 129 | 129 | // we control the regex rule that evaluates when only string arrives. |
| 130 | - if(!preg_match('@'.$regex[1].'@is',$this->inputs[$key])){
|
|
| 131 | - $this->catchException($key,$regex[1]); |
|
| 130 | + if (!preg_match('@'.$regex[1].'@is', $this->inputs[$key])) {
|
|
| 131 | + $this->catchException($key, $regex[1]); |
|
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | } |
@@ -143,9 +143,9 @@ discard block |
||
| 143 | 143 | */ |
| 144 | 144 | private function getRemove($key) |
| 145 | 145 | {
|
| 146 | - if(preg_match('@remove\((.*?)\)\r\n@is',$this->annotation,$remove)){
|
|
| 147 | - if(isset($this->inputs[$key])){
|
|
| 148 | - if(preg_match('@'.$remove[1].'@is',$this->inputs[$key])){
|
|
| 146 | + if (preg_match('@remove\((.*?)\)\r\n@is', $this->annotation, $remove)) {
|
|
| 147 | + if (isset($this->inputs[$key])) {
|
|
| 148 | + if (preg_match('@'.$remove[1].'@is', $this->inputs[$key])) {
|
|
| 149 | 149 | unset($this->inputs[$key]); |
| 150 | 150 | } |
| 151 | 151 | } |
@@ -67,8 +67,7 @@ discard block |
||
| 67 | 67 | if(isset($this->exceptionParams[$key])){
|
| 68 | 68 | $keyParams = ($this->exceptionParams[$key]['params']) ?? []; |
| 69 | 69 | exception($this->exceptionParams[$key]['name'],$keyParams)->unexpectedValue($key.' input value is not valid as format ('.$data.')');
|
| 70 | - } |
|
| 71 | - else{
|
|
| 70 | + } else{
|
|
| 72 | 71 | exception()->unexpectedValue($key.' input value is not valid as format ('.$data.')');
|
| 73 | 72 | } |
| 74 | 73 | } |
@@ -123,8 +122,7 @@ discard block |
||
| 123 | 122 | $this->catchException($key,$regex[1]); |
| 124 | 123 | } |
| 125 | 124 | } |
| 126 | - } |
|
| 127 | - else{
|
|
| 125 | + } else{
|
|
| 128 | 126 | |
| 129 | 127 | // we control the regex rule that evaluates when only string arrives. |
| 130 | 128 | if(!preg_match('@'.$regex[1].'@is',$this->inputs[$key])){
|