| @@ -17,25 +17,25 @@ discard block | ||
| 17 | 17 | public function setConfig($config_file) | 
| 18 | 18 |      { | 
| 19 | 19 | $config = Yaml::parse($config_file); | 
| 20 | -        if ( is_array($config) === false  ) { | |
| 20 | +        if (is_array($config) === false) { | |
| 21 | 21 | $config = Yaml::parse(File::get($config_file)); | 
| 22 | 22 | } | 
| 23 | -        if ( is_array($config) ) { | |
| 24 | - $this->config = array_merge($this->config,$config); | |
| 23 | +        if (is_array($config)) { | |
| 24 | + $this->config = array_merge($this->config, $config); | |
| 25 | 25 | } | 
| 26 | 26 | } | 
| 27 | 27 | public function getConfig() | 
| 28 | 28 |      { | 
| 29 | 29 | return $this->config; | 
| 30 | 30 | } | 
| 31 | - public function setModels($models,$csv) | |
| 31 | + public function setModels($models, $csv) | |
| 32 | 32 |      { | 
| 33 | -        foreach ( $models as $table => $model ) { | |
| 34 | -            if ( is_array($model) ) { | |
| 33 | +        foreach ($models as $table => $model) { | |
| 34 | +            if (is_array($model)) { | |
| 35 | 35 | $total = count($model); | 
| 36 | -                for($i=0;$i<$total;$i++) { | |
| 37 | -                    if ( isset($this->config[$table][$i]) ) { | |
| 38 | - $this->setModel($model[$i],$this->config[$table][$i],$csv,$table); | |
| 36 | +                for ($i = 0; $i < $total; $i++) { | |
| 37 | +                    if (isset($this->config[$table][$i])) { | |
| 38 | + $this->setModel($model[$i], $this->config[$table][$i], $csv, $table); | |
| 39 | 39 |                      } else { | 
| 40 | 40 |                          throw new \Exception('設定ファイルが正しくないか、構成が異なっています。table=' . $table); | 
| 41 | 41 | } | 
| @@ -45,23 +45,23 @@ discard block | ||
| 45 | 45 | return true; | 
| 46 | 46 | } | 
| 47 | 47 | |
| 48 | - public function setModel($model,$config,$csv,$table) | |
| 48 | + public function setModel($model, $config, $csv, $table) | |
| 49 | 49 |      { | 
| 50 | -        foreach ( $config as $key => $rec ) { | |
| 51 | -            if ( isset($rec['func']) === true && $rec['func'] ) { | |
| 50 | +        foreach ($config as $key => $rec) { | |
| 51 | +            if (isset($rec['func']) === true && $rec['func']) { | |
| 52 | 52 | $func = $rec['func']; | 
| 53 | 53 | $col = isset($rec['csv']) ? $rec['csv'] : null; | 
| 54 | -                if ( strpos($col,",") !== false ) { | |
| 55 | -                    $col = explode(",",$col); | |
| 54 | +                if (strpos($col, ",") !== false) { | |
| 55 | +                    $col = explode(",", $col); | |
| 56 | 56 | } | 
| 57 | -                if ( method_exists($this,$func) === true ) { | |
| 58 | - $this->$func($model,$key,$csv,$col); | |
| 57 | +                if (method_exists($this, $func) === true) { | |
| 58 | + $this->$func($model, $key, $csv, $col); | |
| 59 | 59 |                  } else { | 
| 60 | 60 | throw new \Exception(get_class($this) . 'に関数=' . $func . 'が実装されていません。'); | 
| 61 | 61 | } | 
| 62 | -            } elseif ( isset($rec['csv']) && is_numeric($rec['csv']) === true && isset($csv[($rec['csv']+0)-1]) ) { | |
| 62 | +            } elseif (isset($rec['csv']) && is_numeric($rec['csv']) === true && isset($csv[($rec['csv']+0)-1])) { | |
| 63 | 63 | $model->$key = $csv[($rec['csv']+0)-1]; | 
| 64 | -            } elseif ( isset($rec['csv']) && is_numeric($rec['csv']) === false && isset($csv[$rec['csv']]) ) { | |
| 64 | +            } elseif (isset($rec['csv']) && is_numeric($rec['csv']) === false && isset($csv[$rec['csv']])) { | |
| 65 | 65 | $model->$key = $csv[$rec['csv']]; | 
| 66 | 66 |              } else { | 
| 67 | 67 | $model->$key = null; |