@@ -233,8 +233,7 @@ discard block |
||
| 233 | 233 | |
| 234 | 234 | if($default){ |
| 235 | 235 | $search = '/'.$key.'/'; |
| 236 | - } |
|
| 237 | - else{ |
|
| 236 | + } else{ |
|
| 238 | 237 | $search = '/__'.$key.'__/'; |
| 239 | 238 | } |
| 240 | 239 | |
@@ -269,8 +268,7 @@ discard block |
||
| 269 | 268 | { |
| 270 | 269 | if(is_null($stubPath)){ |
| 271 | 270 | $this->stubPath = __DIR__.'/stubs'; |
| 272 | - } |
|
| 273 | - else{ |
|
| 271 | + } else{ |
|
| 274 | 272 | $this->stubPath = $stubPath; |
| 275 | 273 | } |
| 276 | 274 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @param $name |
| 84 | 84 | * @param Filesystem $fileSystem |
| 85 | 85 | */ |
| 86 | - public function __construct($path,$name,Filesystem $fileSystem=null) |
|
| 86 | + public function __construct($path, $name, Filesystem $fileSystem = null) |
|
| 87 | 87 | { |
| 88 | 88 | $this->format = $this->type; |
| 89 | 89 | |
@@ -109,8 +109,8 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | public function createPath() |
| 111 | 111 | { |
| 112 | - if(!file_exists($this->path)){ |
|
| 113 | - if(!$this->fileSystem->makeDirectory($this->path)){ |
|
| 112 | + if (!file_exists($this->path)) { |
|
| 113 | + if (!$this->fileSystem->makeDirectory($this->path)) { |
|
| 114 | 114 | throw new \Error($this->path.' makeDirectory fail'); |
| 115 | 115 | } |
| 116 | 116 | } |
@@ -123,9 +123,9 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | protected function getClassInstance() |
| 125 | 125 | { |
| 126 | - if(!isset($this->loaded['createClass'])){ |
|
| 126 | + if (!isset($this->loaded['createClass'])) { |
|
| 127 | 127 | |
| 128 | - if(is_null(self::$instance)){ |
|
| 128 | + if (is_null(self::$instance)) { |
|
| 129 | 129 | $class = Utils::getNamespace($this->file); |
| 130 | 130 | self::$instance = new $class; |
| 131 | 131 | } |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | protected function getClassString() |
| 158 | 158 | { |
| 159 | - if(preg_match('@'.$this->type.'\s.*\n{@',$this->fileSystem->get($this->file),$parse)){ |
|
| 159 | + if (preg_match('@'.$this->type.'\s.*\n{@', $this->fileSystem->get($this->file), $parse)) { |
|
| 160 | 160 | return $parse[0]; |
| 161 | 161 | } |
| 162 | 162 | |
@@ -169,9 +169,9 @@ discard block |
||
| 169 | 169 | * @param null $eval |
| 170 | 170 | * @return string |
| 171 | 171 | */ |
| 172 | - protected function getEval($eval=null) |
|
| 172 | + protected function getEval($eval = null) |
|
| 173 | 173 | { |
| 174 | - return __DIR__ . '/stubs/evals/' .$eval.'.stub'; |
|
| 174 | + return __DIR__.'/stubs/evals/'.$eval.'.stub'; |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | /** |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | * @param bool $regexEscape |
| 182 | 182 | * @return mixed|string |
| 183 | 183 | */ |
| 184 | - protected function getMethodParameters($method,$regexEscape=true) |
|
| 184 | + protected function getMethodParameters($method, $regexEscape = true) |
|
| 185 | 185 | { |
| 186 | 186 | return (isset($this->methodParameters[$method])) ? |
| 187 | 187 | ($regexEscape) ? $this->regexEscape($this->methodParameters[$method]) : $this->methodParameters[$method] |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | { |
| 198 | 198 | $stubFile = $this->stubPath.''.DIRECTORY_SEPARATOR.''.$this->format.'.stub'; |
| 199 | 199 | |
| 200 | - if(!file_exists($stubFile)){ |
|
| 200 | + if (!file_exists($stubFile)) { |
|
| 201 | 201 | throw new \Error($stubFile.' path is not available'); |
| 202 | 202 | } |
| 203 | 203 | |
@@ -212,10 +212,10 @@ discard block |
||
| 212 | 212 | */ |
| 213 | 213 | protected function regexEscape($data) |
| 214 | 214 | { |
| 215 | - $dataEscape = str_replace('\\','\\\\',$data); |
|
| 216 | - $dataEscape = str_replace('$','\$',$dataEscape); |
|
| 217 | - $dataEscape = str_replace('()','\(\)',$dataEscape); |
|
| 218 | - $dataEscape = str_replace('[]','\[\]',$dataEscape); |
|
| 215 | + $dataEscape = str_replace('\\', '\\\\', $data); |
|
| 216 | + $dataEscape = str_replace('$', '\$', $dataEscape); |
|
| 217 | + $dataEscape = str_replace('()', '\(\)', $dataEscape); |
|
| 218 | + $dataEscape = str_replace('[]', '\[\]', $dataEscape); |
|
| 219 | 219 | |
| 220 | 220 | |
| 221 | 221 | return $dataEscape; |
@@ -231,24 +231,24 @@ discard block |
||
| 231 | 231 | * |
| 232 | 232 | * @throws \Resta\Exception\FileNotFoundException |
| 233 | 233 | */ |
| 234 | - protected function replaceFileContent($replacement,$file,$default=false) |
|
| 234 | + protected function replaceFileContent($replacement, $file, $default = false) |
|
| 235 | 235 | { |
| 236 | 236 | $replacementVariables = ($default) ? $replacement : $this->replacementVariables($replacement); |
| 237 | 237 | $content = $this->fileSystem->get($file); |
| 238 | 238 | |
| 239 | - foreach ($replacementVariables as $key=>$replacementVariable){ |
|
| 239 | + foreach ($replacementVariables as $key=>$replacementVariable) { |
|
| 240 | 240 | |
| 241 | - if($default){ |
|
| 241 | + if ($default) { |
|
| 242 | 242 | $search = '/'.$key.'/'; |
| 243 | 243 | } |
| 244 | - else{ |
|
| 244 | + else { |
|
| 245 | 245 | $search = '/__'.$key.'__/'; |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | $replace = $replacementVariable; |
| 249 | - $content = preg_replace($search,$replace,$content); |
|
| 249 | + $content = preg_replace($search, $replace, $content); |
|
| 250 | 250 | } |
| 251 | - $this->fileSystem->replace($file,$content); |
|
| 251 | + $this->fileSystem->replace($file, $content); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | /** |
@@ -257,12 +257,12 @@ discard block |
||
| 257 | 257 | * @param array $replacement |
| 258 | 258 | * @return array |
| 259 | 259 | */ |
| 260 | - protected function replacementVariables($replacement=array()) |
|
| 260 | + protected function replacementVariables($replacement = array()) |
|
| 261 | 261 | { |
| 262 | 262 | $replacement['namespace'] = $this->namespace; |
| 263 | 263 | $replacement['class'] = $this->name; |
| 264 | 264 | |
| 265 | - return array_map(function($item){ |
|
| 265 | + return array_map(function($item) { |
|
| 266 | 266 | return ucfirst($item); |
| 267 | 267 | },$replacement); |
| 268 | 268 | } |
@@ -276,11 +276,11 @@ discard block |
||
| 276 | 276 | { |
| 277 | 277 | $this->format = $format; |
| 278 | 278 | |
| 279 | - if($this->format=='abstract'){ |
|
| 279 | + if ($this->format=='abstract') { |
|
| 280 | 280 | $this->type = 'abstract class'; |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - if($this->format=='interface'){ |
|
| 283 | + if ($this->format=='interface') { |
|
| 284 | 284 | $this->type = $this->format; |
| 285 | 285 | } |
| 286 | 286 | } |
@@ -290,12 +290,12 @@ discard block |
||
| 290 | 290 | * |
| 291 | 291 | * @param $stubPath |
| 292 | 292 | */ |
| 293 | - public function setStubPath($stubPath=null) |
|
| 293 | + public function setStubPath($stubPath = null) |
|
| 294 | 294 | { |
| 295 | - if(is_null($stubPath)){ |
|
| 295 | + if (is_null($stubPath)) { |
|
| 296 | 296 | $this->stubPath = __DIR__.'/stubs'; |
| 297 | 297 | } |
| 298 | - else{ |
|
| 298 | + else { |
|
| 299 | 299 | $this->stubPath = $stubPath; |
| 300 | 300 | } |
| 301 | 301 | } |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | * Schema constructor. |
| 41 | 41 | * @param null|mixed $config |
| 42 | 42 | */ |
| 43 | - public function __construct($config=null) |
|
| 43 | + public function __construct($config = null) |
|
| 44 | 44 | { |
| 45 | 45 | $this->config = $config; |
| 46 | 46 | $this->driver = $this->config['database']['driver']; |
@@ -28,9 +28,9 @@ discard block |
||
| 28 | 28 | * SchemaFacade constructor. |
| 29 | 29 | * @param array $config |
| 30 | 30 | */ |
| 31 | - public function __construct($config=array()) |
|
| 31 | + public function __construct($config = array()) |
|
| 32 | 32 | { |
| 33 | - if(count($config)){ |
|
| 33 | + if (count($config)) { |
|
| 34 | 34 | $this->schema = new Schema($config); |
| 35 | 35 | } |
| 36 | 36 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @param array $params |
| 42 | 42 | * @return SchemaFacade |
| 43 | 43 | */ |
| 44 | - public static function setConfig($params=array()) |
|
| 44 | + public static function setConfig($params = array()) |
|
| 45 | 45 | { |
| 46 | 46 | self::$config = $params; |
| 47 | 47 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @param array $tables |
| 55 | 55 | * @return SchemaFacade |
| 56 | 56 | */ |
| 57 | - public static function tables($tables=array()) |
|
| 57 | + public static function tables($tables = array()) |
|
| 58 | 58 | { |
| 59 | 59 | self::$tables = $tables; |
| 60 | 60 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public static function getInstance() |
| 70 | 70 | { |
| 71 | - if(is_null(self::$instance)){ |
|
| 71 | + if (is_null(self::$instance)) { |
|
| 72 | 72 | self::$instance = new self(self::$config); |
| 73 | 73 | } |
| 74 | 74 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | protected function getClassName($file) |
| 62 | 62 | { |
| 63 | - $className = str_replace(".php","",BaseRequestProcess::getFileName($file)); |
|
| 63 | + $className = str_replace(".php", "", BaseRequestProcess::getFileName($file)); |
|
| 64 | 64 | |
| 65 | 65 | return $className; |
| 66 | 66 | } |
@@ -100,11 +100,11 @@ discard block |
||
| 100 | 100 | * @param null|string $data |
| 101 | 101 | * @return mixed |
| 102 | 102 | */ |
| 103 | - public function queryBuilder($table=null,$data=null) |
|
| 103 | + public function queryBuilder($table = null, $data = null) |
|
| 104 | 104 | { |
| 105 | 105 | $queryBuilder = $this->queryBuilder; |
| 106 | 106 | |
| 107 | - return new $queryBuilder($this->schema,$table,$data); |
|
| 107 | + return new $queryBuilder($this->schema, $table, $data); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -120,10 +120,10 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | foreach ($this->getAllFiles() as $table=>$allFile) { |
| 122 | 122 | |
| 123 | - if(count($tables)){ |
|
| 123 | + if (count($tables)) { |
|
| 124 | 124 | |
| 125 | - if(in_array($table,$tables)){ |
|
| 126 | - $list[$table]=$allFile; |
|
| 125 | + if (in_array($table, $tables)) { |
|
| 126 | + $list[$table] = $allFile; |
|
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | } |
@@ -136,15 +136,15 @@ discard block |
||
| 136 | 136 | * @param array $params |
| 137 | 137 | * @return mixed |
| 138 | 138 | */ |
| 139 | - public function getContentFile($path,$params=array()) |
|
| 139 | + public function getContentFile($path, $params = array()) |
|
| 140 | 140 | { |
| 141 | 141 | $dt = fopen($path, "r"); |
| 142 | 142 | $content = fread($dt, filesize($path)); |
| 143 | 143 | fclose($dt); |
| 144 | 144 | |
| 145 | - foreach ($params as $key=>$value){ |
|
| 145 | + foreach ($params as $key=>$value) { |
|
| 146 | 146 | |
| 147 | - $content=str_replace("__".$key."__",$value,$content); |
|
| 147 | + $content = str_replace("__".$key."__", $value, $content); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | return $content; |
@@ -29,14 +29,14 @@ |
||
| 29 | 29 | { |
| 30 | 30 | $this->config = $config; |
| 31 | 31 | |
| 32 | - if(is_null(self::$instance)){ |
|
| 32 | + if (is_null(self::$instance)) { |
|
| 33 | 33 | |
| 34 | 34 | //get pdo dsn |
| 35 | - $dsn=''.$config['driver'].':host='.$config['host'].';dbname='.$config['database'].''; |
|
| 35 | + $dsn = ''.$config['driver'].':host='.$config['host'].';dbname='.$config['database'].''; |
|
| 36 | 36 | $this->connection = new \PDO($dsn, $config['user'], $config['password']); |
| 37 | 37 | $this->connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); |
| 38 | 38 | |
| 39 | - self::$instance=true; |
|
| 39 | + self::$instance = true; |
|
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | |
@@ -19,13 +19,13 @@ discard block |
||
| 19 | 19 | * @param $credentials |
| 20 | 20 | * @param $auth |
| 21 | 21 | */ |
| 22 | - public function __construct($credentials,$auth) |
|
| 22 | + public function __construct($credentials, $auth) |
|
| 23 | 23 | {
|
| 24 | 24 | parent::__construct($auth); |
| 25 | 25 | |
| 26 | 26 | // where the control mechanism of the credentials |
| 27 | 27 | // values received from the user-defined yada config setting is made. |
| 28 | - $this->credentials = new AuthLoginCredentialsManager($this->getCredentials($credentials),$this); |
|
| 28 | + $this->credentials = new AuthLoginCredentialsManager($this->getCredentials($credentials), $this); |
|
| 29 | 29 | |
| 30 | 30 | //query login |
| 31 | 31 | $this->loginProcess(); |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | // if the user is not going to use the config setting, |
| 42 | 42 | // then in this case it can attempt to login by sending parameters |
| 43 | 43 | // as an array to the login method. |
| 44 | - if(is_array($credentials) && count($credentials)){
|
|
| 44 | + if (is_array($credentials) && count($credentials)) {
|
|
| 45 | 45 | |
| 46 | 46 | $this->using = true; |
| 47 | 47 | return $credentials; |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | {
|
| 26 | 26 | // if the auth value does not carry |
| 27 | 27 | // the authenticateProvider instance value, an exception is thrown. |
| 28 | - if(!$auth instanceof AuthenticateProvider){
|
|
| 28 | + if (!$auth instanceof AuthenticateProvider) {
|
|
| 29 | 29 | exception()->runtime('AuthenticateProvider instance is not valid');
|
| 30 | 30 | } |
| 31 | 31 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | // the imported builder object. |
| 41 | 41 | $this->driverBuilderInstance = new $driverBuilder($auth); |
| 42 | 42 | |
| 43 | - if(!$this->driverBuilderInstance instanceof BuilderContract){
|
|
| 43 | + if (!$this->driverBuilderInstance instanceof BuilderContract) {
|
|
| 44 | 44 | exception()->runtime($driverBuilder.' is not instance of '.BuilderContract::class); |
| 45 | 45 | } |
| 46 | 46 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | protected function paramValues(...$params) |
| 14 | 14 | {
|
| 15 | - [$type,$query] = $params; |
|
| 15 | + [$type, $query] = $params; |
|
| 16 | 16 | |
| 17 | 17 | // with query we bind the returned values to the params property of the auth object. |
| 18 | 18 | // and so the auth object will make a final return with these values. |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | // if status is true, |
| 24 | 24 | // we add values for some user benefits to params global access. |
| 25 | - if($this->auth->params['status']){
|
|
| 25 | + if ($this->auth->params['status']) {
|
|
| 26 | 26 | |
| 27 | 27 | $this->auth->params['auth'] = $query->get(); |
| 28 | 28 | $this->auth->params['data'] = $query->first(); |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | * @param $auth |
| 15 | 15 | * @param $token |
| 16 | 16 | */ |
| 17 | - public function __construct($auth,$token) |
|
| 17 | + public function __construct($auth, $token) |
|
| 18 | 18 | {
|
| 19 | 19 | parent::__construct($auth); |
| 20 | 20 | |