EnvironManipulatorFactory::getSystemManipulator()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 9
nc 3
nop 0
1
<?php
2
3
namespace Dock\System\Environ;
4
5
class EnvironManipulatorFactory
6
{
7
    /**
8
     * Get environ manipulator based on the current system.
9
     *
10
     * @return EnvironManipulator
11
     */
12
    public function getSystemManipulator()
13
    {
14
        $shell = getenv('SHELL');
15
        $userHome = getenv('HOME');
16
17
        $environFile = $userHome.'/.bash_profile';
18
        if (strpos($shell, 'zsh') !== false) {
19
            $environFile = $userHome.'/.zshrc';
20
        } elseif (strpos($shell, 'fish') !== false) {
21
            $environFile = $userHome.'/.config/fish/config.fish';
22
        }
23
24
        return new FileEnvironManipulator($environFile);
25
    }
26
}
27