Completed
Push — master ( 73e470...c585f2 )
by Amine
01:49
created
src/Template/TemplateLoader.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,11 +19,11 @@
 block discarded – undo
19 19
 
20 20
 	public function load($name)
21 21
 	{
22
-		if(! isset($this->loaded[$name])){
22
+		if (!isset($this->loaded[$name])) {
23 23
 			$path = __DIR__ . "/../../templates/{$name}.wnt";
24 24
 			try {
25 25
 				$this->loaded[$name] = $this->fs->get($path);
26
-			} catch(\Exception $e) {
26
+			} catch (\Exception $e) {
27 27
 				throw new TemplateException("Unable to read the file '{$path}'");
28 28
 			}
29 29
 		}
Please login to merge, or discard this patch.
src/Template/Template.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 
34 34
 	public function with($data = [])
35 35
 	{
36
-		if($data)
36
+		if ($data)
37 37
 			$this->dirty = true;
38 38
 		foreach ($data as $key => $value) {
39 39
 			$this->data[$key] = $value;
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 
44 44
 	public function get()
45 45
 	{
46
-		if($this->dirty){
46
+		if ($this->dirty) {
47 47
 			$this->compile();
48 48
 			$this->dirty = false;
49 49
 		}
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	public function compile()
54 54
 	{
55 55
 		$this->compiled = $this->text;
56
-		foreach($this->data as $key => $value){
56
+		foreach ($this->data as $key => $value) {
57 57
 			$this->compiled = str_replace('{{' . $key . '}}', $value, $this->compiled);
58 58
 		}
59 59
 		return $this;
Please login to merge, or discard this patch.
src/Commands/ModelCommand.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
     protected function getAsArrayFields($arg, $isOption = true)
44 44
     {
45 45
     	$arg = ($isOption) ? $this->option($arg) : $this->argument($arg);
46
-        if(is_string($arg)){
46
+        if (is_string($arg)) {
47 47
         	$arg = explode(',', $arg);
48
-        } else if(! is_array($arg)) {
48
+        } else if (!is_array($arg)) {
49 49
             $arg = [];
50 50
         }
51
-        return implode(', ', array_map(function($item){
51
+        return implode(', ', array_map(function($item) {
52 52
             return '"' . $item . '"';
53 53
         }, $arg));
54 54
     }
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
             $this->getRelationsByType('belongsToMany', 'belongs-to-many', true)
68 68
         );
69 69
 
70
-        if(empty($relations)){
70
+        if (empty($relations)) {
71 71
             return "    // Relationships";
72 72
         }
73 73
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
     {
79 79
         $relations = [];
80 80
         $option = $this->option($option);
81
-        if($option){
81
+        if ($option) {
82 82
 
83 83
             $items = $this->getArgumentParser('relations')->parse($option);
84 84
 
@@ -86,9 +86,9 @@  discard block
 block discarded – undo
86 86
             $template = $this->getTemplate($template);
87 87
             foreach ($items as $item) {
88 88
                 $item['type'] = $type;
89
-                if(! $item['model']){
89
+                if (!$item['model']) {
90 90
                     $item['model'] = $this->getNamespace() . '\\' . ucwords(str_singular($item['name']));
91
-                } else if(strpos($item['model'], '\\') === false ){
91
+                } else if (strpos($item['model'], '\\') === false) {
92 92
                     $item['model'] = $this->getNamespace() . '\\' . $item['model'];
93 93
                 }
94 94
                 $relations[] = $template->with($item)->get();
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
     protected function getRules()
101 101
     {
102 102
         $rules = $this->option('rules');
103
-        if(! $rules){
103
+        if (!$rules) {
104 104
             return "        // Validation rules";
105 105
         }
106 106
         $items = $rules;
107
-        if(! $this->option('parsed')){
107
+        if (!$this->option('parsed')) {
108 108
             $items = $this->getArgumentParser('rules')->parse($rules);
109 109
         }
110 110
         $rules = [];
Please login to merge, or discard this patch.
src/Commands/BaseCommand.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
         return $this->templates->load($name);
27 27
     }
28 28
 
29
-    protected function getArgumentParser($name){
29
+    protected function getArgumentParser($name) {
30 30
         $format = $this->argumentFormatLoader->load($name);
31 31
         return new ArgumentParser($format);
32 32
     }
Please login to merge, or discard this patch.
src/Commands/FactoryCommand.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     protected function getFile()
35 35
     {
36 36
         $file = $this->option('file');
37
-        if(! $file){
37
+        if (!$file) {
38 38
             $file = './database/factories/ModelFactory.php';
39 39
         }
40 40
         return $file;
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
 
47 47
         $fields = $this->option('fields');
48 48
 
49
-        if($fields){
50
-            if(! $this->option('parsed')){
49
+        if ($fields) {
50
+            if (!$this->option('parsed')) {
51 51
                 $fields = $this->getArgumentParser('factory-fields')->parse($fields);
52 52
             }
53 53
             $template = $this->getTemplate('factory/field');
54
-            foreach($fields as $field){
54
+            foreach ($fields as $field) {
55 55
                 $content[] = $template->with($field)->get();
56 56
             }
57 57
             $content = implode(PHP_EOL, $content);
Please login to merge, or discard this patch.
src/Commands/PivotSeederCommand.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
     }
46 46
 
47 47
     protected function getSeederName($resources) {
48
-        $resources = array_map(function($resource){
48
+        $resources = array_map(function($resource) {
49 49
             return ucwords(camel_case($resource));
50 50
         }, $resources);
51 51
         return implode('', $resources) . 'TableSeeder';
Please login to merge, or discard this patch.
src/Commands/PivotTableCommand.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,14 +41,14 @@
 block discarded – undo
41 41
 
42 42
     protected function schema()
43 43
     {
44
-        return implode(' ', array_map(function($table){
44
+        return implode(' ', array_map(function($table) {
45 45
             return $table . '_id:integer:unsigned:index';
46 46
         }, $this->tables));
47 47
     }
48 48
 
49 49
     protected function keys()
50 50
     {
51
-        return implode(' ', array_map(function($table){
51
+        return implode(' ', array_map(function($table) {
52 52
             return $table . '_id';
53 53
         }, $this->tables));
54 54
     }
Please login to merge, or discard this patch.
src/Commands/MigrationCommand.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
             ->get();
34 34
 
35 35
         $file = $this->option('file');
36
-        if(! $file){
36
+        if (!$file) {
37 37
             $file = date('Y_m_d_His_') . snake_case($name) . '_table';
38 38
         }
39 39
 
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
     protected function getSchema()
44 44
     {
45 45
         $schema = $this->option('schema');
46
-        if(! $schema){
46
+        if (!$schema) {
47 47
             return $this->spaces(12) . "// Schema declaration";
48 48
         }
49 49
 
50 50
         $items = $schema;
51
-        if( ! $this->option('parsed')){
51
+        if (!$this->option('parsed')) {
52 52
             $items = $this->getArgumentParser('schema')->parse($schema);
53 53
         }
54 54
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
         $name = $parts[0]['name'];
83 83
         $parts[1]['args'] = array_merge(["'{$name}'"], $parts[1]['args']);
84 84
         unset($parts[0]);
85
-        $parts = array_map(function($part){
85
+        $parts = array_map(function($part) {
86 86
             return '->' . $part['name'] . '(' . implode(', ', $part['args']) . ')';
87 87
         }, $parts);
88 88
         return "            \$table" . implode('', $parts) . ';';
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
     protected function getConstraints()
92 92
     {
93 93
         $keys = $this->option('keys');
94
-        if(! $keys){
94
+        if (!$keys) {
95 95
             return $this->spaces(12) . "// Constraints declaration";
96 96
         }
97 97
 
98 98
         $items = $keys;
99
-        if(! $this->option('parsed')){
99
+        if (!$this->option('parsed')) {
100 100
             $items = $this->getArgumentParser('foreign-keys')->parse($keys);
101 101
         }
102 102
 
@@ -110,10 +110,10 @@  discard block
 block discarded – undo
110 110
 
111 111
     protected function getConstraintDeclaration($key)
112 112
     {
113
-        if(! $key['column']){
113
+        if (!$key['column']) {
114 114
             $key['column'] = 'id';
115 115
         }
116
-        if(! $key['table']){
116
+        if (!$key['table']) {
117 117
             $key['table'] = str_plural(substr($key['name'], 0, count($key['name']) - 4));
118 118
         }
119 119
 
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
             ])
126 126
             ->get();
127 127
 
128
-        if($key['on_delete']){
128
+        if ($key['on_delete']) {
129 129
             $constraint .= PHP_EOL . $this->getTemplate('migration/on-constraint')
130 130
                 ->with([
131 131
                     'event' => 'Delete',
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
                 ->get();
135 135
         }
136 136
 
137
-        if($key['on_update']){
137
+        if ($key['on_update']) {
138 138
             $constraint .= PHP_EOL . $this->getTemplate('migration/on-constraint')
139 139
                 ->with([
140 140
                     'event' => 'Update',
Please login to merge, or discard this patch.
src/Argument/ArgumentFormatLoader.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -19,15 +19,15 @@  discard block
 block discarded – undo
19 19
 
20 20
 	public function load($name)
21 21
 	{
22
-    	if(! isset($this->loaded[$name])){
22
+    	if (!isset($this->loaded[$name])) {
23 23
     		$path = __DIR__ . "/../../formats/{$name}.json";
24 24
     		$json = "";
25 25
 			try {
26 26
 				$json = json_decode($this->fs->get($path));
27
-			} catch(\Exception $e) {
27
+			} catch (\Exception $e) {
28 28
 				throw new ArgumentFormatException("Unable to read the file '{$path}'");
29 29
 			}
30
-			if (json_last_error() !== JSON_ERROR_NONE){
30
+			if (json_last_error() !== JSON_ERROR_NONE) {
31 31
 				throw new ArgumentFormatException("Error while parsing the JSON file '{$path}'");
32 32
 			}
33 33
 			$this->loaded[$name] = $this->buildFormat($json);
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	    return $format;
82 82
 	}
83 83
 
84
-	protected function fillObject($obj, $firstLevel=false)
84
+	protected function fillObject($obj, $firstLevel = false)
85 85
 	{
86 86
 	    $format = new ArgumentFormat;
87 87
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	        if (isset($obj->separator)) {
108 108
 	            $format->separator = $obj->separator;
109 109
 	        } elseif ($firstLevel) {
110
-	           $format->separator = ($format->type === 'object') ? ':':',';
110
+	           $format->separator = ($format->type === 'object') ? ':' : ',';
111 111
 	        }
112 112
 	    }
113 113
 
Please login to merge, or discard this patch.