@@ -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,16 +62,16 @@ 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 | |
| 69 | 69 | $keyParams = ($this->exceptionParams[$key]['params']) ?? []; |
| 70 | 70 | |
| 71 | - exception($this->exceptionParams[$key]['name'],$keyParams) |
|
| 71 | + exception($this->exceptionParams[$key]['name'], $keyParams) |
|
| 72 | 72 | ->unexpectedValue($key.' input value is not valid as format ('.$data.')');
|
| 73 | 73 | } |
| 74 | - else{
|
|
| 74 | + else {
|
|
| 75 | 75 | |
| 76 | 76 | exception() |
| 77 | 77 | ->unexpectedValue($key.' input value is not valid as format ('.$data.')');
|
@@ -86,20 +86,20 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | private function getException($key) |
| 88 | 88 | {
|
| 89 | - if(preg_match('@exception\((.*?)\)\r\n@is',$this->annotation,$exception)){
|
|
| 89 | + if (preg_match('@exception\((.*?)\)\r\n@is', $this->annotation, $exception)) {
|
|
| 90 | 90 | |
| 91 | - $exceptionSpaceExplode = explode(" ",$exception[1]);
|
|
| 92 | - foreach ($exceptionSpaceExplode as $exceptions){
|
|
| 93 | - $exceptionsDotExplode = explode(":",$exceptions);
|
|
| 91 | + $exceptionSpaceExplode = explode(" ", $exception[1]);
|
|
| 92 | + foreach ($exceptionSpaceExplode as $exceptions) {
|
|
| 93 | + $exceptionsDotExplode = explode(":", $exceptions);
|
|
| 94 | 94 | $this->exceptionParams[$key][$exceptionsDotExplode[0]] = $exceptionsDotExplode[1]; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - if(isset($this->exceptionParams[$key]['params'])){
|
|
| 98 | - $paramsCommaExplode = explode(",",$this->exceptionParams[$key]['params']);
|
|
| 97 | + if (isset($this->exceptionParams[$key]['params'])) {
|
|
| 98 | + $paramsCommaExplode = explode(",", $this->exceptionParams[$key]['params']);
|
|
| 99 | 99 | unset($this->exceptionParams[$key]['params']); |
| 100 | - foreach ($paramsCommaExplode as $params){
|
|
| 101 | - $paramsEqualExplode = explode("=",$params);
|
|
| 102 | - if(isset($paramsEqualExplode[0]) && isset($paramsEqualExplode[1])){
|
|
| 100 | + foreach ($paramsCommaExplode as $params) {
|
|
| 101 | + $paramsEqualExplode = explode("=", $params);
|
|
| 102 | + if (isset($paramsEqualExplode[0]) && isset($paramsEqualExplode[1])) {
|
|
| 103 | 103 | $this->exceptionParams[$key]['params'][$paramsEqualExplode[0]] = $paramsEqualExplode[1]; |
| 104 | 104 | } |
| 105 | 105 | } |
@@ -116,24 +116,24 @@ discard block |
||
| 116 | 116 | {
|
| 117 | 117 | // with the method based regex annotation, |
| 118 | 118 | // we check the rule definition for our requests. |
| 119 | - if(preg_match('@regex\((.*?)\)\r\n@is',$this->annotation,$regex)){
|
|
| 120 | - if(isset($this->inputs[$key])){
|
|
| 119 | + if (preg_match('@regex\((.*?)\)\r\n@is', $this->annotation, $regex)) {
|
|
| 120 | + if (isset($this->inputs[$key])) {
|
|
| 121 | 121 | |
| 122 | 122 | // for the definition of rules, |
| 123 | 123 | // our inputs can be array and in this case we offer array option for user comfort. |
| 124 | - if(is_array($this->inputs[$key])){
|
|
| 124 | + if (is_array($this->inputs[$key])) {
|
|
| 125 | 125 | |
| 126 | - foreach ($this->inputs[$key] as $this->inputsKey=>$this->inputsValue){
|
|
| 127 | - if(!preg_match('@'.$regex[1].'@is',$this->inputsValue)){
|
|
| 128 | - $this->catchException($key,$regex[1]); |
|
| 126 | + foreach ($this->inputs[$key] as $this->inputsKey=>$this->inputsValue) {
|
|
| 127 | + if (!preg_match('@'.$regex[1].'@is', $this->inputsValue)) {
|
|
| 128 | + $this->catchException($key, $regex[1]); |
|
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | - else{
|
|
| 132 | + else {
|
|
| 133 | 133 | |
| 134 | 134 | // we control the regex rule that evaluates when only string arrives. |
| 135 | - if(!preg_match('@'.$regex[1].'@is',$this->inputs[$key])){
|
|
| 136 | - $this->catchException($key,$regex[1]); |
|
| 135 | + if (!preg_match('@'.$regex[1].'@is', $this->inputs[$key])) {
|
|
| 136 | + $this->catchException($key, $regex[1]); |
|
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | } |
@@ -148,9 +148,9 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | private function getRemove($key) |
| 150 | 150 | {
|
| 151 | - if(preg_match('@remove\((.*?)\)\r\n@is',$this->annotation,$remove)){
|
|
| 152 | - if(isset($this->inputs[$key])){
|
|
| 153 | - if(preg_match('@'.$remove[1].'@is',$this->inputs[$key])){
|
|
| 151 | + if (preg_match('@remove\((.*?)\)\r\n@is', $this->annotation, $remove)) {
|
|
| 152 | + if (isset($this->inputs[$key])) {
|
|
| 153 | + if (preg_match('@'.$remove[1].'@is', $this->inputs[$key])) {
|
|
| 154 | 154 | unset($this->inputs[$key]); |
| 155 | 155 | } |
| 156 | 156 | } |
@@ -70,8 +70,7 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | exception($this->exceptionParams[$key]['name'],$keyParams) |
| 72 | 72 | ->unexpectedValue($key.' input value is not valid as format ('.$data.')');
|
| 73 | - } |
|
| 74 | - else{
|
|
| 73 | + } else{
|
|
| 75 | 74 | |
| 76 | 75 | exception() |
| 77 | 76 | ->unexpectedValue($key.' input value is not valid as format ('.$data.')');
|
@@ -128,8 +127,7 @@ discard block |
||
| 128 | 127 | $this->catchException($key,$regex[1]); |
| 129 | 128 | } |
| 130 | 129 | } |
| 131 | - } |
|
| 132 | - else{
|
|
| 130 | + } else{
|
|
| 133 | 131 | |
| 134 | 132 | // we control the regex rule that evaluates when only string arrives. |
| 135 | 133 | if(!preg_match('@'.$regex[1].'@is',$this->inputs[$key])){
|