Test Failed
Push — master ( 106ac2...59efbe )
by Yuichi
03:21
created
src/Imports/AbstractImport.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -10,34 +10,34 @@  discard block
 block discarded – undo
10 10
     protected $config;
11 11
     private $filesystem;
12 12
 
13
-    public function __construct(Filesystem $filesystem=null)
13
+    public function __construct(Filesystem $filesystem = null)
14 14
     {
15 15
         $this->config = [];
16 16
         $this->filesystem = $filesystem ? $filesystem : new Filesystem;
17 17
     }
18 18
 
19
-    public function setConfig($config_file,$is_force=false)
19
+    public function setConfig($config_file, $is_force = false)
20 20
     {
21 21
         $config = Yaml::parse($config_file);
22
-        if ( is_array($config) === false || $is_force ) {
22
+        if (is_array($config) === false || $is_force) {
23 23
             $config = Yaml::parse($this->filesystem->get($config_file));
24 24
         }
25
-        if ( is_array($config) ) {
26
-            $this->config = array_merge($this->config,$config);
25
+        if (is_array($config)) {
26
+            $this->config = array_merge($this->config, $config);
27 27
         }
28 28
     }
29 29
     public function getConfig()
30 30
     {
31 31
         return $this->config;
32 32
     }
33
-    public function setModels($models,$csv)
33
+    public function setModels($models, $csv)
34 34
     {
35
-        foreach ( $models as $table => $model ) {
36
-            if ( is_array($model) ) {
35
+        foreach ($models as $table => $model) {
36
+            if (is_array($model)) {
37 37
                 $total = count($model);
38
-                for($i=0;$i<$total;$i++) {
39
-                    if ( isset($this->config[$table][$i]) ) {
40
-                        $this->setModel($model[$i],$this->config[$table][$i],$csv,$table);
38
+                for ($i = 0; $i < $total; $i++) {
39
+                    if (isset($this->config[$table][$i])) {
40
+                        $this->setModel($model[$i], $this->config[$table][$i], $csv, $table);
41 41
                     } else {
42 42
                         throw new \Exception('設定ファイルが正しくないか、構成が異なっています。table=' . $table);
43 43
                     }
@@ -47,23 +47,23 @@  discard block
 block discarded – undo
47 47
         return true;
48 48
     }
49 49
 
50
-    public function setModel($model,$config,$csv,$table)
50
+    public function setModel($model, $config, $csv, $table)
51 51
     {
52
-        foreach ( $config as $key => $rec ) {
53
-            if ( isset($rec['func']) === true && $rec['func'] ) {
52
+        foreach ($config as $key => $rec) {
53
+            if (isset($rec['func']) === true && $rec['func']) {
54 54
                 $func = $rec['func'];
55 55
                 $col = isset($rec['csv']) ? $rec['csv'] : null;
56
-                if ( strpos($col,",") !== false ) {
57
-                    $col = explode(",",$col);
56
+                if (strpos($col, ",") !== false) {
57
+                    $col = explode(",", $col);
58 58
                 }
59
-                if ( method_exists($this,$func) === true ) {
60
-                    $this->$func($model,$key,$csv,$col);
59
+                if (method_exists($this, $func) === true) {
60
+                    $this->$func($model, $key, $csv, $col);
61 61
                 } else {
62 62
                     throw new \Exception(get_class($this) . 'に関数=' . $func . 'が実装されていません。');
63 63
                 }
64
-            } elseif ( isset($rec['csv']) && is_numeric($rec['csv']) === true && isset($csv[($rec['csv']+0)-1]) ) {
64
+            } elseif (isset($rec['csv']) && is_numeric($rec['csv']) === true && isset($csv[($rec['csv']+0)-1])) {
65 65
                 $model->$key = $csv[($rec['csv']+0)-1];
66
-            } elseif ( isset($rec['csv']) && is_numeric($rec['csv']) === false && isset($csv[$rec['csv']]) ) {
66
+            } elseif (isset($rec['csv']) && is_numeric($rec['csv']) === false && isset($csv[$rec['csv']])) {
67 67
                 $model->$key = $csv[$rec['csv']];
68 68
             } else {
69 69
                 $model->$key = null;
Please login to merge, or discard this patch.