AppExport::getOptions()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 10
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 10
loc 10
rs 9.4285
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
namespace CsvCombine\Export;
3
4
/**
5
 * AppExport
6
 * Export系のまとめ
7
 * @author hagiwara
8
 */
9 View Code Duplication
class AppExport {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
    protected $_defaultOptions = [
11
        'line_feed_code' => "\r\n",
12
        'export_encoding' => 'SJIS-win',
13
        'array_encoding' => 'UTF-8',
14
        // csvのみのオプション
15
        'delimiter' => ',',
16
        // 固定長のみのオプション
17
        'extra_fixed_options' => []
18
    ];
19
20
    /**
21
     * getOptions
22
     * 使用オプションのまとめ
23
     * @author hagiwara
24
     */
25
    protected function getOptions($options)
26
    {
27
        $options = array_merge($this->_defaultOptions, $options);
28
        // キーをすべてキャメライズする
29
        foreach ($options as $optionKey => $optionVal) {
30
            unset($options[$optionKey]);
31
            $options[$this->camelize($optionKey)] = $optionVal;
32
        }
33
        return $options;
34
    }
35
36
    /**
37
     * camelize
38
     * https://qiita.com/okapon_pon/items/498b88c2f91d7c42e9e8
39
     */
40
    private function camelize($str)
41
    {
42
        return lcfirst(strtr(ucwords(strtr($str, ['_' => ' '])), [' ' => '']));
43
    }
44
}
45