Code Duplication    Length = 31-31 lines in 2 locations

src/Export/AppExport.php 1 location

@@ 9-39 (lines=31) @@
6
 * Export系のまとめ
7
 * @author hagiwara
8
 */
9
class AppExport {
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, ['_' => ' '])), [' ' => '']));

src/Import/AppImport.php 1 location

@@ 9-39 (lines=31) @@
6
 * Import系のまとめ
7
 * @author hagiwara
8
 */
9
class AppImport {
10
    protected $_defaultOptions = [
11
        'line_feed_code' => "\r\n",
12
        'array_encoding' => 'UTF-8',
13
        'import_encoding' => 'SJIS-win',
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, ['_' => ' '])), [' ' => '']));