Code Duplication    Length = 36-36 lines in 2 locations

src/CommandFactory/EditorFactory.php 1 location

@@ 13-48 (lines=36) @@
10
/**
11
 * Uses the EditorStrategy to locate an editor.
12
 */
13
class EditorFactory
14
{
15
    use CommandFactoryTrait;
16
17
    /** @type \Nubs\Sensible\Strategy\PagerStrategy The pager strategy. */
18
    private $_strategy;
19
20
    /**
21
     * Create the editor.
22
     *
23
     * @api
24
     * @param \Nubs\Which\Locator $commandLocator The command locator.  This
25
     *     helps locate commands using PATH.
26
     * @param string[] $editors The names to the potential editors.  The first
27
     *     command in the list that can be located will be used.
28
     * @param \Habitat\Environment\Environment $environment The environment
29
     *     variable wrapper.  Defaults to null, which just uses the built-in
30
     *     getenv.
31
     */
32
    public function __construct(CommandLocator $commandLocator, array $editors = ['sensible-editor', 'nano', 'vim', 'ed'], Environment $environment = null)
33
    {
34
        $this->_strategy = new EditorStrategy($editors, $commandLocator, $environment);
35
    }
36
37
    /**
38
     * Create the editor object using the strategy.
39
     *
40
     * @api
41
     * @return \Nubs\Sensible\Editor The created editor object.
42
     * @throws \Exception if no editor can be found.
43
     */
44
    public function create()
45
    {
46
        return new Editor($this->getCommand($this->_strategy));
47
    }
48
}
49

src/CommandFactory/PagerFactory.php 1 location

@@ 13-48 (lines=36) @@
10
/**
11
 * Uses the PagerStrategy to locate a pager.
12
 */
13
class PagerFactory
14
{
15
    use CommandFactoryTrait;
16
17
    /** @type \Nubs\Sensible\Strategy\PagerFactory The pager strategy. */
18
    private $_strategy;
19
20
    /**
21
     * Create the pager.
22
     *
23
     * @api
24
     * @param \Nubs\Which\Locator $commandLocator The command locator.  This
25
     *     helps locate commands using PATH.
26
     * @param string[] $pagers The names to the potential pagers.  The first
27
     *     command in the list that can be located will be used.
28
     * @param \Habitat\Environment\Environment $environment The environment
29
     *     variable wrapper.  Defaults to null, which just uses the built-in
30
     *     getenv.
31
     */
32
    public function __construct(CommandLocator $commandLocator, array $pagers = ['sensible-pager', 'less', 'more'], Environment $environment = null)
33
    {
34
        $this->_strategy = new PagerStrategy($pagers, $commandLocator, $environment);
35
    }
36
37
    /**
38
     * Create the pager object using the strategy.
39
     *
40
     * @api
41
     * @return \Nubs\Sensible\Pager The created pager object.
42
     * @throws \Exception if no pager can be found.
43
     */
44
    public function create()
45
    {
46
        return new Pager($this->getCommand($this->_strategy));
47
    }
48
}
49