@@ -5,7 +5,7 @@ |
||
| 5 | 5 | |
| 6 | 6 | class User extends Eloquent |
| 7 | 7 | {
|
| 8 | - protected $hidden = ['id','password','token']; |
|
| 8 | + protected $hidden = ['id', 'password', 'token']; |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * User constructor. |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | /** |
| 33 | 33 | * @var array |
| 34 | 34 | */ |
| 35 | - public $commandRule=['name','client']; |
|
| 35 | + public $commandRule = ['name', 'client']; |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * @method create |
@@ -56,35 +56,35 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | $this->argument['managerTraitNamespace'] = Utils::getNamespace($this->directory['clientNameDir'].'/'.$name.'Trait.php'); |
| 58 | 58 | |
| 59 | - if(!file_exists($manager = $this->directory['clientNameDir'].'/'.$name.'Manager.php')){
|
|
| 59 | + if (!file_exists($manager = $this->directory['clientNameDir'].'/'.$name.'Manager.php')) {
|
|
| 60 | 60 | $this->touch['client/manager'] = $manager; |
| 61 | 61 | $this->touch['client/managertrait'] = $this->directory['clientNameDir'].'/'.$name.'Trait.php'; |
| 62 | 62 | |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if(isset($this->argument['trait'])){
|
|
| 65 | + if (isset($this->argument['trait'])) {
|
|
| 66 | 66 | $this->argument['name'] = $this->argument['trait']; |
| 67 | 67 | |
| 68 | - if(!file_exists($managerCustomTrait = $this->directory['clientNameDir'].'/'.$this->argument['trait'].'Trait.php')){
|
|
| 68 | + if (!file_exists($managerCustomTrait = $this->directory['clientNameDir'].'/'.$this->argument['trait'].'Trait.php')) {
|
|
| 69 | 69 | $this->touch['client/managercustomtrait'] = $managerCustomTrait; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | $this->argument['managerTraitNamespace'] = Utils::getNamespace($managerCustomTrait); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - if(!file_exists($this->directory['clientNameCreate'].'/Client.php')){
|
|
| 75 | + if (!file_exists($this->directory['clientNameCreate'].'/Client.php')) {
|
|
| 76 | 76 | $this->touch['client/client'] = $this->directory['clientNameCreate'].'/Client.php'; |
| 77 | 77 | $this->touch['client/clientGenerator'] = $this->directory['clientNameCreate'].'/ClientGenerator.php'; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | $clientSourceNamespace = Utils::getNamespace($this->directory['clientSource'].'/'.$client.'.php'); |
| 81 | 81 | |
| 82 | - if(!file_exists($clientSourceName = $this->directory['clientSource'].'/'.$client.'.php')){
|
|
| 82 | + if (!file_exists($clientSourceName = $this->directory['clientSource'].'/'.$client.'.php')) {
|
|
| 83 | 83 | $this->touch['client/source'] = $clientSourceName.''; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | |
| 87 | - if(!file_exists($this->directory['clientNameCreate'].'/ClientProvider.php')){
|
|
| 87 | + if (!file_exists($this->directory['clientNameCreate'].'/ClientProvider.php')) {
|
|
| 88 | 88 | $this->touch['client/clientProvider'] = $this->directory['clientNameCreate'].'/ClientProvider.php'; |
| 89 | 89 | } |
| 90 | 90 | |
@@ -98,13 +98,13 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | $nameGeneratorNamespace = Utils::getNamespace($managerPath = $this->directory['clientNameDir'].''.DIRECTORY_SEPARATOR.''.$nameManager.'.php'); |
| 100 | 100 | |
| 101 | - $generator = new Generator(path()->version(),'ClientManager'); |
|
| 101 | + $generator = new Generator(path()->version(), 'ClientManager'); |
|
| 102 | 102 | |
| 103 | 103 | $clientManager = app()->namespace()->version().'\\ClientManager'; |
| 104 | 104 | |
| 105 | 105 | $clientManagerResolve = new $clientManager; |
| 106 | 106 | |
| 107 | - if(!method_exists($clientManagerResolve,strtolower($name))){
|
|
| 107 | + if (!method_exists($clientManagerResolve, strtolower($name))) {
|
|
| 108 | 108 | |
| 109 | 109 | $generator->createMethod([ |
| 110 | 110 | strtolower($name) |
@@ -135,11 +135,11 @@ discard block |
||
| 135 | 135 | |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - $nameGenerator = new Generator($this->directory['clientNameDir'],$name.'Manager'); |
|
| 138 | + $nameGenerator = new Generator($this->directory['clientNameDir'], $name.'Manager'); |
|
| 139 | 139 | |
| 140 | 140 | $nameGeneratorNamespaceResolve = new $nameGeneratorNamespace; |
| 141 | 141 | |
| 142 | - if(!method_exists($nameGeneratorNamespaceResolve,strtolower($client))){
|
|
| 142 | + if (!method_exists($nameGeneratorNamespaceResolve, strtolower($client))) {
|
|
| 143 | 143 | |
| 144 | 144 | $nameGenerator->createMethod([ |
| 145 | 145 | strtolower($client) |
@@ -219,8 +219,7 @@ |
||
| 219 | 219 | $table = $this->config['guard'][$this->guard]['deviceTokenRegister']; |
| 220 | 220 | |
| 221 | 221 | app()->register('authenticateDeviceTokenTable',$table);
|
| 222 | - } |
|
| 223 | - else{
|
|
| 222 | + } else{
|
|
| 224 | 223 | app()->register('authenticateDeviceTokenTable','device_tokens');
|
| 225 | 224 | } |
| 226 | 225 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | {
|
| 32 | 32 | $this->config(); |
| 33 | 33 | |
| 34 | - if($this->guard=="default"){
|
|
| 34 | + if ($this->guard=="default") {
|
|
| 35 | 35 | $this->setAuthenticateNeeds(); |
| 36 | 36 | } |
| 37 | 37 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | {
|
| 50 | 50 | $this->config = config('authenticate');
|
| 51 | 51 | |
| 52 | - if(!is_null($config = $this->provider('configuration'))){
|
|
| 52 | + if (!is_null($config = $this->provider('configuration'))) {
|
|
| 53 | 53 | $this->config['guard'][$this->guard] = $config($this->config['guard'][$this->guard]); |
| 54 | 54 | } |
| 55 | 55 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public function getAddToWhere() |
| 65 | 65 | {
|
| 66 | - if(isset($this->config['guard'][$this->guard]['addToWhere'])){
|
|
| 66 | + if (isset($this->config['guard'][$this->guard]['addToWhere'])) {
|
|
| 67 | 67 | return $this->config['guard'][$this->guard]['addToWhere']; |
| 68 | 68 | } |
| 69 | 69 | return null; |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public function getConfigToken() |
| 78 | 78 | {
|
| 79 | - if(isset($this->config['guard'][$this->guard]['token'])){
|
|
| 79 | + if (isset($this->config['guard'][$this->guard]['token'])) {
|
|
| 80 | 80 | return $this->config['guard'][$this->guard]['token']; |
| 81 | 81 | } |
| 82 | 82 | return null; |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | public function provider($key) |
| 172 | 172 | {
|
| 173 | - if(app()->has('authenticate.'.$key) && is_callable($provider = app()->get('authenticate.'.$key))){
|
|
| 173 | + if (app()->has('authenticate.'.$key) && is_callable($provider = app()->get('authenticate.'.$key))) {
|
|
| 174 | 174 | return $provider; |
| 175 | 175 | } |
| 176 | 176 | |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | {
|
| 210 | 210 | $table = $this->config['guard'][$this->guard]['table']; |
| 211 | 211 | |
| 212 | - app()->register('authenticateTable',$table);
|
|
| 212 | + app()->register('authenticateTable', $table);
|
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -219,13 +219,13 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | public function deviceTokenTable() |
| 221 | 221 | {
|
| 222 | - if(isset($this->config['guard'][$this->guard]['deviceTokenRegister'])){
|
|
| 222 | + if (isset($this->config['guard'][$this->guard]['deviceTokenRegister'])) {
|
|
| 223 | 223 | $table = $this->config['guard'][$this->guard]['deviceTokenRegister']; |
| 224 | 224 | |
| 225 | - app()->register('authenticateDeviceTokenTable',$table);
|
|
| 225 | + app()->register('authenticateDeviceTokenTable', $table);
|
|
| 226 | 226 | } |
| 227 | - else{
|
|
| 228 | - app()->register('authenticateDeviceTokenTable','device_tokens');
|
|
| 227 | + else {
|
|
| 228 | + app()->register('authenticateDeviceTokenTable', 'device_tokens');
|
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | } |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | /** |
| 9 | 9 | * @var array |
| 10 | 10 | */ |
| 11 | - protected $fillable = ['user_id','token','token_integer','device_agent','device_agent_integer','expire']; |
|
| 11 | + protected $fillable = ['user_id', 'token', 'token_integer', 'device_agent', 'device_agent_integer', 'expire']; |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * User constructor. |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @param callable $callback |
| 30 | 30 | * @return mixed |
| 31 | 31 | */ |
| 32 | - public function exclude($middleware,callable $callback) |
|
| 32 | + public function exclude($middleware, callable $callback) |
|
| 33 | 33 | {
|
| 34 | 34 | $this->result = true; |
| 35 | 35 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | //if there is exclude method |
| 43 | 43 | //in service middleware class |
| 44 | - if($this->existMethod()){
|
|
| 44 | + if ($this->existMethod()) {
|
|
| 45 | 45 | |
| 46 | 46 | //call exclude method |
| 47 | 47 | /** |
@@ -50,24 +50,24 @@ discard block |
||
| 50 | 50 | $serviceMiddleware = $middleware['class']; |
| 51 | 51 | $excludes = $serviceMiddleware->exclude(); |
| 52 | 52 | |
| 53 | - foreach ($excludes as $excludeKey=>$excludeVal){
|
|
| 54 | - $this->excludeProcess($excludeKey,$excludeVal); |
|
| 53 | + foreach ($excludes as $excludeKey=>$excludeVal) {
|
|
| 54 | + $this->excludeProcess($excludeKey, $excludeVal); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | //return true |
| 59 | - return Utils::returnCallback($this->result,$callback); |
|
| 59 | + return Utils::returnCallback($this->result, $callback); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * @param $excludeKey |
| 64 | 64 | * @param $excludeVal |
| 65 | 65 | */ |
| 66 | - private function excludeProcess($excludeKey,$excludeVal) |
|
| 66 | + private function excludeProcess($excludeKey, $excludeVal) |
|
| 67 | 67 | {
|
| 68 | - $this->excludeForAll($excludeKey,$excludeVal,function() use ($excludeKey,$excludeVal){
|
|
| 68 | + $this->excludeForAll($excludeKey, $excludeVal, function() use ($excludeKey, $excludeVal){
|
|
| 69 | 69 | |
| 70 | - if($excludeKey == $this->excludeList['middleware']['middlewareName']){
|
|
| 70 | + if ($excludeKey==$this->excludeList['middleware']['middlewareName']) {
|
|
| 71 | 71 | $this->result = true; |
| 72 | 72 | $this->inArrayExclude($excludeVal); |
| 73 | 73 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | private function existMethod() |
| 82 | 82 | {
|
| 83 | - return Utils::existMethod($this->excludeList['middleware']['class'],'exclude'); |
|
| 83 | + return Utils::existMethod($this->excludeList['middleware']['class'], 'exclude'); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -88,8 +88,8 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | private function inArrayExclude($exclude) |
| 90 | 90 | {
|
| 91 | - foreach($exclude as $item){
|
|
| 92 | - if(in_array($item,$this->middleware['odds'])){
|
|
| 91 | + foreach ($exclude as $item) {
|
|
| 92 | + if (in_array($item, $this->middleware['odds'])) {
|
|
| 93 | 93 | $this->result = false; |
| 94 | 94 | } |
| 95 | 95 | } |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * @param callable $callback |
| 102 | 102 | * @return mixed |
| 103 | 103 | */ |
| 104 | - private function excludeForAll($excludeKey,$excludeVal,callable $callback) |
|
| 104 | + private function excludeForAll($excludeKey, $excludeVal, callable $callback) |
|
| 105 | 105 | {
|
| 106 | 106 | return ($excludeKey=="all") ? $this->inArrayExclude($excludeVal) : call_user_func($callback); |
| 107 | 107 | } |
@@ -27,13 +27,13 @@ discard block |
||
| 27 | 27 | {
|
| 28 | 28 | // we check that they are in |
| 29 | 29 | // the console to run the console commands in the kernel. |
| 30 | - if(Utils::isNamespaceExists($this->consoleClassNamespace)){
|
|
| 30 | + if (Utils::isNamespaceExists($this->consoleClassNamespace)) {
|
|
| 31 | 31 | return call_user_func($callback); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | // if the kernel console is not found |
| 35 | 35 | // then we check the existence of the specific application command and run it if it is. |
| 36 | - return (new CustomConsoleProcess($this->getConsoleArgumentsWithKey(),$this))->handle(); |
|
| 36 | + return (new CustomConsoleProcess($this->getConsoleArgumentsWithKey(), $this))->handle(); |
|
| 37 | 37 | |
| 38 | 38 | } |
| 39 | 39 | |
@@ -43,29 +43,29 @@ discard block |
||
| 43 | 43 | * @param array $args |
| 44 | 44 | * @return void|mixed |
| 45 | 45 | */ |
| 46 | - protected function consoleEventHandler($args=array()) |
|
| 46 | + protected function consoleEventHandler($args = array()) |
|
| 47 | 47 | {
|
| 48 | - if(isset($this->app['eventDispatcher'])){
|
|
| 48 | + if (isset($this->app['eventDispatcher'])) {
|
|
| 49 | 49 | |
| 50 | 50 | $listeners = event()->getListeners(); |
| 51 | 51 | |
| 52 | - if(isset($args['event']) && isset($listeners['console'])){
|
|
| 52 | + if (isset($args['event']) && isset($listeners['console'])) {
|
|
| 53 | 53 | |
| 54 | - if(strtolower($args['event'])!=='default' && isset($listeners['console'][strtolower($args['event'])])){
|
|
| 54 | + if (strtolower($args['event'])!=='default' && isset($listeners['console'][strtolower($args['event'])])) {
|
|
| 55 | 55 | |
| 56 | 56 | $event = $listeners['console'][strtolower($args['event'])]; |
| 57 | - return call_user_func_array($event,['app'=>$this->app,'args'=>$args,]); |
|
| 57 | + return call_user_func_array($event, ['app'=>$this->app, 'args'=>$args, ]); |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - if(isset($listeners['console']['default'])){
|
|
| 61 | + if (isset($listeners['console']['default'])) {
|
|
| 62 | 62 | |
| 63 | - if($this->app->has('arguments')){
|
|
| 64 | - $args = array_merge($args,$this->app->get('arguments'));
|
|
| 63 | + if ($this->app->has('arguments')) {
|
|
| 64 | + $args = array_merge($args, $this->app->get('arguments'));
|
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | $event = $listeners['console']['default']; |
| 68 | - return call_user_func_array($event,['args'=>$args,'app'=>$this->app]); |
|
| 68 | + return call_user_func_array($event, ['args'=>$args, 'app'=>$this->app]); |
|
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | 71 | |
@@ -83,9 +83,9 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | //If the console executor is a custom console application; in this case we look at the kernel directory inside the application. |
| 85 | 85 | //If the console class is not available on the kernel of resta, then the system will run the command class in the application. |
| 86 | - return $this->checkConsoleNamespace(function(){
|
|
| 86 | + return $this->checkConsoleNamespace(function() {
|
|
| 87 | 87 | |
| 88 | - if($this->isRunnableKernelCommandList()){
|
|
| 88 | + if ($this->isRunnableKernelCommandList()) {
|
|
| 89 | 89 | exception()->badMethodCall('this command is not runnable');
|
| 90 | 90 | } |
| 91 | 91 | |
@@ -93,10 +93,10 @@ discard block |
||
| 93 | 93 | $consoleArguments = $this->getConsoleArgumentsWithKey(); |
| 94 | 94 | |
| 95 | 95 | // we get the instance data of the kernel command class of the system. |
| 96 | - $commander = (new $this->consoleClassNamespace($consoleArguments,$this)); |
|
| 96 | + $commander = (new $this->consoleClassNamespace($consoleArguments, $this)); |
|
| 97 | 97 | |
| 98 | 98 | // we check the command rules of each command class. |
| 99 | - $this->prepareCommander($commander,function($commander){
|
|
| 99 | + $this->prepareCommander($commander, function($commander) {
|
|
| 100 | 100 | return $commander->{$this->getConsoleClassMethod()}();
|
| 101 | 101 | }); |
| 102 | 102 | |
@@ -114,12 +114,12 @@ discard block |
||
| 114 | 114 | public function handle() |
| 115 | 115 | {
|
| 116 | 116 | //get is running console |
| 117 | - if($this->app->runningInConsole()){
|
|
| 117 | + if ($this->app->runningInConsole()) {
|
|
| 118 | 118 | |
| 119 | 119 | error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); |
| 120 | 120 | |
| 121 | 121 | //run console process |
| 122 | - if(count($this->getArguments())){
|
|
| 122 | + if (count($this->getArguments())) {
|
|
| 123 | 123 | return $this->consoleProcess(); |
| 124 | 124 | } |
| 125 | 125 | |
@@ -135,24 +135,24 @@ discard block |
||
| 135 | 135 | * @param callable $callback |
| 136 | 136 | * @return mixed |
| 137 | 137 | */ |
| 138 | - protected function prepareCommander(ConsoleOutputterContracts $commander,callable $callback) |
|
| 138 | + protected function prepareCommander(ConsoleOutputterContracts $commander, callable $callback) |
|
| 139 | 139 | {
|
| 140 | 140 | // closure binding custom command,move custom namespace as specific |
| 141 | 141 | // call prepare commander firstly for checking command builder |
| 142 | - $closureCommand = app()->resolve(ClosureDispatcher::class,['bind'=>$commander]); |
|
| 142 | + $closureCommand = app()->resolve(ClosureDispatcher::class, ['bind'=>$commander]); |
|
| 143 | 143 | |
| 144 | 144 | //assign commander method name |
| 145 | 145 | $closureCommand->prepareBind['methodName'] = $this->getConsoleClassMethod(); |
| 146 | 146 | |
| 147 | 147 | $prepareCommander = $commander->prepareCommander($closureCommand); |
| 148 | 148 | |
| 149 | - if(!$prepareCommander['status']){
|
|
| 149 | + if (!$prepareCommander['status']) {
|
|
| 150 | 150 | echo $commander->exception($prepareCommander); |
| 151 | 151 | die(); |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | //callback custom console |
| 155 | - return call_user_func_array($callback,[$commander]); |
|
| 155 | + return call_user_func_array($callback, [$commander]); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
@@ -165,8 +165,8 @@ discard block |
||
| 165 | 165 | $commandList = $this->app->commandList(); |
| 166 | 166 | |
| 167 | 167 | //is runnable kernel command conditions |
| 168 | - return !array_key_exists($this->consoleClassNamespace,$commandList) OR |
|
| 169 | - (array_key_exists($this->consoleClassNamespace,$commandList) AND |
|
| 168 | + return !array_key_exists($this->consoleClassNamespace, $commandList) OR |
|
| 169 | + (array_key_exists($this->consoleClassNamespace, $commandList) AND |
|
| 170 | 170 | !$commandList[$this->consoleClassNamespace]['isRunnable']); |
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | \ No newline at end of file |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | public function handle() |
| 24 | 24 | { |
| 25 | - foreach ($this->tableFilters() as $table=>$files){ |
|
| 25 | + foreach ($this->tableFilters() as $table=>$files) { |
|
| 26 | 26 | |
| 27 | 27 | $table = strtolower($table); |
| 28 | 28 | |
@@ -30,20 +30,20 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | $checkMigrationMain = $this->schema->getConnection()->checkMigrationMain(); |
| 32 | 32 | |
| 33 | - if($checkMigrationMain===false && isset($this->tableFilters()['Migrations'][0])){ |
|
| 34 | - $this->apply($this->tableFilters()['Migrations'][0],'migrations'); |
|
| 33 | + if ($checkMigrationMain===false && isset($this->tableFilters()['Migrations'][0])) { |
|
| 34 | + $this->apply($this->tableFilters()['Migrations'][0], 'migrations'); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - $checkMigration = $this->schema->getConnection()->checkMigration($table,$file); |
|
| 37 | + $checkMigration = $this->schema->getConnection()->checkMigration($table, $file); |
|
| 38 | 38 | |
| 39 | - if(!$checkMigration){ |
|
| 39 | + if (!$checkMigration) { |
|
| 40 | 40 | |
| 41 | - $getClassName = preg_replace('@(\d+)_@is','',$file); |
|
| 41 | + $getClassName = preg_replace('@(\d+)_@is', '', $file); |
|
| 42 | 42 | $className = $this->getClassName($getClassName); |
| 43 | 43 | |
| 44 | 44 | require_once ($file); |
| 45 | 45 | |
| 46 | - $capsule = new SchemaCapsule($this->config,$file,$table); |
|
| 46 | + $capsule = new SchemaCapsule($this->config, $file, $table); |
|
| 47 | 47 | |
| 48 | 48 | $this->list[$table][] = (new $className)->up($capsule); |
| 49 | 49 | |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - app()->register('arguments','connection',$this->schema->getConnection()); |
|
| 54 | + app()->register('arguments', 'connection', $this->schema->getConnection()); |
|
| 55 | 55 | return $this->processHandler(); |
| 56 | 56 | } |
| 57 | 57 | |
@@ -60,14 +60,14 @@ discard block |
||
| 60 | 60 | * @param $table |
| 61 | 61 | * @return mixed|string |
| 62 | 62 | */ |
| 63 | - public function apply($file,$table) |
|
| 63 | + public function apply($file, $table) |
|
| 64 | 64 | { |
| 65 | - $getClassName = preg_replace('@(\d+)_@is','',$file); |
|
| 65 | + $getClassName = preg_replace('@(\d+)_@is', '', $file); |
|
| 66 | 66 | $className = $this->getClassName($getClassName); |
| 67 | 67 | |
| 68 | 68 | require_once ($file); |
| 69 | 69 | |
| 70 | - $capsule = new SchemaCapsule($this->config,$file,$table); |
|
| 70 | + $capsule = new SchemaCapsule($this->config, $file, $table); |
|
| 71 | 71 | |
| 72 | 72 | $this->list[$table][] = (new $className)->up($capsule); |
| 73 | 73 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * @param null $default |
| 21 | 21 | * @return mixed |
| 22 | 22 | */ |
| 23 | - public function input($key, $default=null); |
|
| 23 | + public function input($key, $default = null); |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * @param $key |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @param $value |
| 46 | 46 | * @return void |
| 47 | 47 | */ |
| 48 | - public function set($key,$value); |
|
| 48 | + public function set($key, $value); |
|
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | 51 | * @return mixed |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * @param ApplicationContracts $app |
| 26 | 26 | * @param $request |
| 27 | 27 | */ |
| 28 | - public function __construct(ApplicationContracts $app,$request) |
|
| 28 | + public function __construct(ApplicationContracts $app, $request) |
|
| 29 | 29 | {
|
| 30 | 30 | parent::__construct($app); |
| 31 | 31 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @param $key |
| 42 | 42 | * @return mixed|void |
| 43 | 43 | */ |
| 44 | - public function annotation($method,$key) |
|
| 44 | + public function annotation($method, $key) |
|
| 45 | 45 | {
|
| 46 | 46 | //set annotation value with getting reflection |
| 47 | 47 | $reflection = $this->getReflection('reflection')->reflectionMethodParams($method);
|
@@ -66,18 +66,18 @@ discard block |
||
| 66 | 66 | * @param string $key |
| 67 | 67 | * @param null|string $data |
| 68 | 68 | */ |
| 69 | - private function catchException($key,$data) |
|
| 69 | + private function catchException($key, $data) |
|
| 70 | 70 | {
|
| 71 | - if(isset($this->exceptionParams[$key])){
|
|
| 71 | + if (isset($this->exceptionParams[$key])) {
|
|
| 72 | 72 | |
| 73 | 73 | //get key params for exception params |
| 74 | 74 | $keyParams = ($this->exceptionParams[$key]['params']) ?? []; |
| 75 | 75 | |
| 76 | 76 | //catch exception |
| 77 | - exception($this->exceptionParams[$key]['name'],$keyParams) |
|
| 77 | + exception($this->exceptionParams[$key]['name'], $keyParams) |
|
| 78 | 78 | ->unexpectedValue($this->exceptionParams[$key]['name'].' input value is not valid as format ('.$data.')');
|
| 79 | 79 | } |
| 80 | - else{
|
|
| 80 | + else {
|
|
| 81 | 81 | //catch exception |
| 82 | 82 | exception()->unexpectedValue($key.' input value is not valid as format ('.$data.')');
|
| 83 | 83 | } |
@@ -90,23 +90,23 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | private function getException($key) |
| 92 | 92 | {
|
| 93 | - if(preg_match('@exception\((.*?)\)|exception\((.*?)\)\r\n@is',$this->annotation,$exception)){
|
|
| 93 | + if (preg_match('@exception\((.*?)\)|exception\((.*?)\)\r\n@is', $this->annotation, $exception)) {
|
|
| 94 | 94 | |
| 95 | - $exceptionSpaceExplode = explode(" ",$exception[1]);
|
|
| 95 | + $exceptionSpaceExplode = explode(" ", $exception[1]);
|
|
| 96 | 96 | |
| 97 | - foreach ($exceptionSpaceExplode as $exceptions){
|
|
| 98 | - $exceptionsDotExplode = explode(":",$exceptions);
|
|
| 97 | + foreach ($exceptionSpaceExplode as $exceptions) {
|
|
| 98 | + $exceptionsDotExplode = explode(":", $exceptions);
|
|
| 99 | 99 | $this->exceptionParams[$key][$exceptionsDotExplode[0]] = $exceptionsDotExplode[1]; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - if(isset($this->exceptionParams[$key]['params'])){
|
|
| 102 | + if (isset($this->exceptionParams[$key]['params'])) {
|
|
| 103 | 103 | |
| 104 | - $paramsCommaExplode = explode(",",$this->exceptionParams[$key]['params']);
|
|
| 104 | + $paramsCommaExplode = explode(",", $this->exceptionParams[$key]['params']);
|
|
| 105 | 105 | unset($this->exceptionParams[$key]['params']); |
| 106 | 106 | |
| 107 | - foreach ($paramsCommaExplode as $params){
|
|
| 108 | - $paramsEqualExplode = explode("=",$params);
|
|
| 109 | - if(isset($paramsEqualExplode[0]) && isset($paramsEqualExplode[1])){
|
|
| 107 | + foreach ($paramsCommaExplode as $params) {
|
|
| 108 | + $paramsEqualExplode = explode("=", $params);
|
|
| 109 | + if (isset($paramsEqualExplode[0]) && isset($paramsEqualExplode[1])) {
|
|
| 110 | 110 | $this->exceptionParams[$key]['params'][$paramsEqualExplode[0]] = $paramsEqualExplode[1]; |
| 111 | 111 | } |
| 112 | 112 | } |
@@ -123,37 +123,37 @@ discard block |
||
| 123 | 123 | {
|
| 124 | 124 | // with the method based regex annotation, |
| 125 | 125 | // we check the rule definition for our requests. |
| 126 | - if(preg_match('@regex\((.*?)\)|regex\((.*?)\)\r\n@is',$this->annotation,$regex)){
|
|
| 127 | - if(isset($this->inputs[$key])){
|
|
| 126 | + if (preg_match('@regex\((.*?)\)|regex\((.*?)\)\r\n@is', $this->annotation, $regex)) {
|
|
| 127 | + if (isset($this->inputs[$key])) {
|
|
| 128 | 128 | |
| 129 | 129 | // for the definition of rules, |
| 130 | 130 | // our inputs can be array and in this case we offer array option for user comfort. |
| 131 | - if(is_array($this->inputs[$key])){
|
|
| 131 | + if (is_array($this->inputs[$key])) {
|
|
| 132 | 132 | |
| 133 | - foreach ($this->inputs[$key] as $this->inputsKey => $this->inputsValue){
|
|
| 133 | + foreach ($this->inputs[$key] as $this->inputsKey => $this->inputsValue) {
|
|
| 134 | 134 | |
| 135 | - if(is_array($this->inputsValue)){
|
|
| 135 | + if (is_array($this->inputsValue)) {
|
|
| 136 | 136 | |
| 137 | - foreach ($this->inputsValue as $inputsValueKey => $inputsValueItem){
|
|
| 138 | - if(!preg_match('@'.$regex[1].'@is',$inputsValueItem)){
|
|
| 139 | - $this->catchException($key,$regex[1]); |
|
| 137 | + foreach ($this->inputsValue as $inputsValueKey => $inputsValueItem) {
|
|
| 138 | + if (!preg_match('@'.$regex[1].'@is', $inputsValueItem)) {
|
|
| 139 | + $this->catchException($key, $regex[1]); |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | } |
| 144 | - else{
|
|
| 145 | - if(!preg_match('@'.$regex[1].'@is',$this->inputsValue)){
|
|
| 146 | - $this->catchException($key,$regex[1]); |
|
| 144 | + else {
|
|
| 145 | + if (!preg_match('@'.$regex[1].'@is', $this->inputsValue)) {
|
|
| 146 | + $this->catchException($key, $regex[1]); |
|
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | } |
| 151 | 151 | } |
| 152 | - else{
|
|
| 152 | + else {
|
|
| 153 | 153 | |
| 154 | 154 | // we control the regex rule that evaluates when only string arrives. |
| 155 | - if(!preg_match('@'.$regex[1].'@is',$this->inputs[$key])){
|
|
| 156 | - $this->catchException($key,$regex[1]); |
|
| 155 | + if (!preg_match('@'.$regex[1].'@is', $this->inputs[$key])) {
|
|
| 156 | + $this->catchException($key, $regex[1]); |
|
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | } |
@@ -168,9 +168,9 @@ discard block |
||
| 168 | 168 | */ |
| 169 | 169 | private function getRemove($key) |
| 170 | 170 | {
|
| 171 | - if(preg_match('@remove\((.*?)\)\r\n@is',$this->annotation,$remove)){
|
|
| 172 | - if(isset($this->inputs[$key])){
|
|
| 173 | - if(preg_match('@'.$remove[1].'@is',$this->inputs[$key])){
|
|
| 171 | + if (preg_match('@remove\((.*?)\)\r\n@is', $this->annotation, $remove)) {
|
|
| 172 | + if (isset($this->inputs[$key])) {
|
|
| 173 | + if (preg_match('@'.$remove[1].'@is', $this->inputs[$key])) {
|
|
| 174 | 174 | unset($this->inputs[$key]); |
| 175 | 175 | } |
| 176 | 176 | } |
@@ -184,33 +184,33 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | private function getRules($key) |
| 186 | 186 | {
|
| 187 | - if(preg_match('@rule\((.*?)\)|rule\((.*?)\)\r\n@is',$this->annotation,$rule)){
|
|
| 187 | + if (preg_match('@rule\((.*?)\)|rule\((.*?)\)\r\n@is', $this->annotation, $rule)) {
|
|
| 188 | 188 | |
| 189 | 189 | $requestRules = $this->getReflection('rules');
|
| 190 | 190 | |
| 191 | - $rules = explode(":",$rule[1]);
|
|
| 192 | - if(isset($this->inputs[$key]) && !is_array($this->inputs[$key])){
|
|
| 193 | - foreach($rules as $rule){
|
|
| 191 | + $rules = explode(":", $rule[1]);
|
|
| 192 | + if (isset($this->inputs[$key]) && !is_array($this->inputs[$key])) {
|
|
| 193 | + foreach ($rules as $rule) {
|
|
| 194 | 194 | |
| 195 | - $ruleExplode = explode('#',$rule);
|
|
| 195 | + $ruleExplode = explode('#', $rule);
|
|
| 196 | 196 | $rule = $ruleExplode[0]; |
| 197 | 197 | |
| 198 | - if(isset($requestRules[$rule])){
|
|
| 199 | - if(!preg_match('@'.$requestRules[$rule].'@',$this->inputs[$key])){
|
|
| 200 | - exception($rule,['key'=>$key.':'.$this->inputs[$key]]) |
|
| 198 | + if (isset($requestRules[$rule])) {
|
|
| 199 | + if (!preg_match('@'.$requestRules[$rule].'@', $this->inputs[$key])) {
|
|
| 200 | + exception($rule, ['key'=>$key.':'.$this->inputs[$key]]) |
|
| 201 | 201 | ->invalidArgument($key.':'.$this->inputs[$key].' input value is not valid for '.$rule.' request rule'); |
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | //rule method |
| 206 | - if(!isset($requestRules[$rule])){
|
|
| 207 | - $this->request->call(function() use($rule,$key,$ruleExplode){
|
|
| 208 | - if(method_exists($this,$ruleMethod = '__rule'.ucfirst($rule))){
|
|
| 209 | - if(isset($ruleExplode[1])){
|
|
| 206 | + if (!isset($requestRules[$rule])) {
|
|
| 207 | + $this->request->call(function() use($rule, $key, $ruleExplode){
|
|
| 208 | + if (method_exists($this, $ruleMethod = '__rule'.ucfirst($rule))) {
|
|
| 209 | + if (isset($ruleExplode[1])) {
|
|
| 210 | 210 | |
| 211 | 211 | $reValueList = []; |
| 212 | - foreach (explode(',',$ruleExplode[1]) as $reValue){
|
|
| 213 | - $reValueExplode = explode('=',$reValue);
|
|
| 212 | + foreach (explode(',', $ruleExplode[1]) as $reValue) {
|
|
| 213 | + $reValueExplode = explode('=', $reValue);
|
|
| 214 | 214 | $reValueListKey = $reValueExplode[0]; |
| 215 | 215 | $reValueListValue = (isset($reValueExplode[1])) ? $reValueExplode[1] : null; |
| 216 | 216 | |
@@ -218,10 +218,10 @@ discard block |
||
| 218 | 218 | |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - $this->{$ruleMethod}($key,$this->inputs[$key],$reValueList);
|
|
| 221 | + $this->{$ruleMethod}($key, $this->inputs[$key], $reValueList);
|
|
| 222 | 222 | } |
| 223 | - else{
|
|
| 224 | - $this->{$ruleMethod}($key,$this->inputs[$key]);
|
|
| 223 | + else {
|
|
| 224 | + $this->{$ruleMethod}($key, $this->inputs[$key]);
|
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | } |
@@ -229,27 +229,27 @@ discard block |
||
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | 231 | } |
| 232 | - else{
|
|
| 232 | + else {
|
|
| 233 | 233 | |
| 234 | - foreach ($this->inputs[$key] as $ikey=>$input){
|
|
| 234 | + foreach ($this->inputs[$key] as $ikey=>$input) {
|
|
| 235 | 235 | |
| 236 | - if(!is_array($input)){
|
|
| 237 | - foreach($rules as $rule){
|
|
| 238 | - if(isset($requestRules[$rule])){
|
|
| 239 | - if(!preg_match('@'.$requestRules[$rule].'@',$input)){
|
|
| 240 | - exception($rule,['key'=>''.$key.':'.$input]) |
|
| 236 | + if (!is_array($input)) {
|
|
| 237 | + foreach ($rules as $rule) {
|
|
| 238 | + if (isset($requestRules[$rule])) {
|
|
| 239 | + if (!preg_match('@'.$requestRules[$rule].'@', $input)) {
|
|
| 240 | + exception($rule, ['key'=>''.$key.':'.$input]) |
|
| 241 | 241 | ->invalidArgument($key.':'.$input.' input value is not valid for '.$rule.' request rule'); |
| 242 | 242 | } |
| 243 | 243 | } |
| 244 | 244 | } |
| 245 | 245 | } |
| 246 | - else{
|
|
| 246 | + else {
|
|
| 247 | 247 | |
| 248 | - foreach ($input as $ikey=>$item){
|
|
| 249 | - foreach($rules as $rule){
|
|
| 250 | - if(isset($requestRules[$rule])){
|
|
| 251 | - if(!preg_match('@'.$requestRules[$rule].'@',$item)){
|
|
| 252 | - exception($rule,['key'=>''.$key.':'.$item]) |
|
| 248 | + foreach ($input as $ikey=>$item) {
|
|
| 249 | + foreach ($rules as $rule) {
|
|
| 250 | + if (isset($requestRules[$rule])) {
|
|
| 251 | + if (!preg_match('@'.$requestRules[$rule].'@', $item)) {
|
|
| 252 | + exception($rule, ['key'=>''.$key.':'.$item]) |
|
| 253 | 253 | ->invalidArgument($key.':'.$item.' input value is not valid for '.$rule.' request rule'); |
| 254 | 254 | } |
| 255 | 255 | } |
@@ -76,8 +76,7 @@ discard block |
||
| 76 | 76 | //catch exception |
| 77 | 77 | exception($this->exceptionParams[$key]['name'],$keyParams) |
| 78 | 78 | ->unexpectedValue($this->exceptionParams[$key]['name'].' input value is not valid as format ('.$data.')');
|
| 79 | - } |
|
| 80 | - else{
|
|
| 79 | + } else{
|
|
| 81 | 80 | //catch exception |
| 82 | 81 | exception()->unexpectedValue($key.' input value is not valid as format ('.$data.')');
|
| 83 | 82 | } |
@@ -140,16 +139,14 @@ discard block |
||
| 140 | 139 | } |
| 141 | 140 | } |
| 142 | 141 | |
| 143 | - } |
|
| 144 | - else{
|
|
| 142 | + } else{
|
|
| 145 | 143 | if(!preg_match('@'.$regex[1].'@is',$this->inputsValue)){
|
| 146 | 144 | $this->catchException($key,$regex[1]); |
| 147 | 145 | } |
| 148 | 146 | } |
| 149 | 147 | |
| 150 | 148 | } |
| 151 | - } |
|
| 152 | - else{
|
|
| 149 | + } else{
|
|
| 153 | 150 | |
| 154 | 151 | // we control the regex rule that evaluates when only string arrives. |
| 155 | 152 | if(!preg_match('@'.$regex[1].'@is',$this->inputs[$key])){
|
@@ -219,8 +216,7 @@ discard block |
||
| 219 | 216 | } |
| 220 | 217 | |
| 221 | 218 | $this->{$ruleMethod}($key,$this->inputs[$key],$reValueList);
|
| 222 | - } |
|
| 223 | - else{
|
|
| 219 | + } else{
|
|
| 224 | 220 | $this->{$ruleMethod}($key,$this->inputs[$key]);
|
| 225 | 221 | } |
| 226 | 222 | |
@@ -228,8 +224,7 @@ discard block |
||
| 228 | 224 | }); |
| 229 | 225 | } |
| 230 | 226 | } |
| 231 | - } |
|
| 232 | - else{
|
|
| 227 | + } else{
|
|
| 233 | 228 | |
| 234 | 229 | foreach ($this->inputs[$key] as $ikey=>$input){
|
| 235 | 230 | |
@@ -242,8 +237,7 @@ discard block |
||
| 242 | 237 | } |
| 243 | 238 | } |
| 244 | 239 | } |
| 245 | - } |
|
| 246 | - else{
|
|
| 240 | + } else{
|
|
| 247 | 241 | |
| 248 | 242 | foreach ($input as $ikey=>$item){
|
| 249 | 243 | foreach($rules as $rule){
|