EnvironManipulatorFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 22
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getSystemManipulator() 0 14 3
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