@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @param ApplicationContracts $app |
| 22 | 22 | * @param $request |
| 23 | 23 | */ |
| 24 | - public function __construct(ApplicationContracts $app,$request) |
|
| 24 | + public function __construct(ApplicationContracts $app, $request) |
|
| 25 | 25 | {
|
| 26 | 26 | parent::__construct($app); |
| 27 | 27 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @param $key |
| 38 | 38 | * @return mixed|void |
| 39 | 39 | */ |
| 40 | - public function annotation($method,$key) |
|
| 40 | + public function annotation($method, $key) |
|
| 41 | 41 | {
|
| 42 | 42 | //set annotation value with getting reflection |
| 43 | 43 | $reflection = $this->getReflection('reflection')->reflectionMethodParams($method);
|
@@ -59,18 +59,18 @@ discard block |
||
| 59 | 59 | * @param $key |
| 60 | 60 | * @param $data |
| 61 | 61 | */ |
| 62 | - private function catchException($key,$data) |
|
| 62 | + private function catchException($key, $data) |
|
| 63 | 63 | {
|
| 64 | - if(isset($this->exceptionParams[$key])){
|
|
| 64 | + if (isset($this->exceptionParams[$key])) {
|
|
| 65 | 65 | |
| 66 | 66 | //get key params for exception params |
| 67 | 67 | $keyParams = ($this->exceptionParams[$key]['params']) ?? []; |
| 68 | 68 | |
| 69 | 69 | //catch exception |
| 70 | - exception($this->exceptionParams[$key]['name'],$keyParams) |
|
| 70 | + exception($this->exceptionParams[$key]['name'], $keyParams) |
|
| 71 | 71 | ->unexpectedValue($key.' input value is not valid as format ('.$data.')');
|
| 72 | 72 | } |
| 73 | - else{
|
|
| 73 | + else {
|
|
| 74 | 74 | //catch exception |
| 75 | 75 | exception()->unexpectedValue($key.' input value is not valid as format ('.$data.')');
|
| 76 | 76 | } |
@@ -83,23 +83,23 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | private function getException($key) |
| 85 | 85 | {
|
| 86 | - if(preg_match('@exception\((.*?)\)\r\n@is',$this->annotation,$exception)){
|
|
| 86 | + if (preg_match('@exception\((.*?)\)\r\n@is', $this->annotation, $exception)) {
|
|
| 87 | 87 | |
| 88 | - $exceptionSpaceExplode = explode(" ",$exception[1]);
|
|
| 88 | + $exceptionSpaceExplode = explode(" ", $exception[1]);
|
|
| 89 | 89 | |
| 90 | - foreach ($exceptionSpaceExplode as $exceptions){
|
|
| 91 | - $exceptionsDotExplode = explode(":",$exceptions);
|
|
| 90 | + foreach ($exceptionSpaceExplode as $exceptions) {
|
|
| 91 | + $exceptionsDotExplode = explode(":", $exceptions);
|
|
| 92 | 92 | $this->exceptionParams[$key][$exceptionsDotExplode[0]] = $exceptionsDotExplode[1]; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - if(isset($this->exceptionParams[$key]['params'])){
|
|
| 95 | + if (isset($this->exceptionParams[$key]['params'])) {
|
|
| 96 | 96 | |
| 97 | - $paramsCommaExplode = explode(",",$this->exceptionParams[$key]['params']);
|
|
| 97 | + $paramsCommaExplode = explode(",", $this->exceptionParams[$key]['params']);
|
|
| 98 | 98 | unset($this->exceptionParams[$key]['params']); |
| 99 | 99 | |
| 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 | } |
@@ -69,8 +69,7 @@ discard block |
||
| 69 | 69 | //catch exception |
| 70 | 70 | exception($this->exceptionParams[$key]['name'],$keyParams) |
| 71 | 71 | ->unexpectedValue($key.' input value is not valid as format ('.$data.')');
|
| 72 | - } |
|
| 73 | - else{
|
|
| 72 | + } else{
|
|
| 74 | 73 | //catch exception |
| 75 | 74 | exception()->unexpectedValue($key.' input value is not valid as format ('.$data.')');
|
| 76 | 75 | } |
@@ -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])){
|