@@ -10,34 +10,34 @@ discard block |
||
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 |
||
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; |
@@ -37,7 +37,7 @@ |
||
37 | 37 | protected function addTree(&$tree, $data) |
38 | 38 | { |
39 | 39 | foreach ($tree as $id => &$rec) { |
40 | - if ( $data->parent_id == $id ) { |
|
40 | + if ($data->parent_id == $id) { |
|
41 | 41 | $data->children = []; |
42 | 42 | $rec->children[$data->id] = $data; |
43 | 43 | return; |
@@ -9,7 +9,7 @@ |
||
9 | 9 | { |
10 | 10 | if (($fp = @fopen($file, "r")) !== false) { |
11 | 11 | |
12 | - while(($data = fgetcsv($fp, $length, $delimiter, $envlosure, $escape)) !== false) { |
|
12 | + while (($data = fgetcsv($fp, $length, $delimiter, $envlosure, $escape)) !== false) { |
|
13 | 13 | $this->csvRecord($data); |
14 | 14 | } |
15 | 15 | fclose($fp); |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | use Carbon\Carbon; |
3 | 3 | |
4 | 4 | if ( ! function_exists('strtodate')) { |
5 | - function strtodate($date, $format='Y/m/d') |
|
5 | + function strtodate($date, $format = 'Y/m/d') |
|
6 | 6 | { |
7 | 7 | if ($date) { |
8 | 8 | return date($format, strtotime($date)); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | function ym($ym) |
16 | 16 | { |
17 | 17 | if ($ym && $ym > 190001) { |
18 | - return (floor($ym/100)) . '年' . ( floor($ym%100)) . '月'; |
|
18 | + return (floor($ym/100)) . '年' . (floor($ym%100)) . '月'; |
|
19 | 19 | } |
20 | 20 | return null; |
21 | 21 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! function_exists('numeric_format') ) { |
|
3 | +if ( ! function_exists('numeric_format')) { |
|
4 | 4 | function numeric_format($val) |
5 | 5 | { |
6 | 6 | $number = str_replace(",", "", $val); |