EditorStrategy   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
namespace Nubs\Sensible\Strategy;
3
4
use Habitat\Environment\Environment;
5
use Nubs\Which\Locator as CommandLocator;
6
7
/**
8
 * Uses the EnvironmentVariableStrategy (EDITOR) and CommandLocatorStrategy to
9
 * create an Editor.
10
 */
11 View Code Duplication
class EditorStrategy extends ListStrategy implements StrategyInterface
12
{
13
    /**
14
     * Initialize the editor strategy.
15
     *
16
     * @param string[] $editors The names to the potential editors.  The first
17
     *     command in the list that can be located will be used.
18
     * @param \Nubs\Which\Locator $commandLocator The command locator.  This
19
     *     helps locate commands using PATH.
20
     * @param \Habitat\Environment\Environment $environment The environment
21
     *     variable wrapper.  Defaults to null, which just uses the built-in
22
     *     getenv.
23
     */
24
    public function __construct(array $editors, CommandLocator $commandLocator, Environment $environment = null)
25
    {
26
        parent::__construct([new EnvironmentVariableStrategy('EDITOR', $environment), new CommandLocatorStrategy($editors, $commandLocator)]);
27
    }
28
}
29