HostsPluginChecker::verify()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 2
1
<?php namespace Magestead\Helper;
2
3
use Symfony\Component\Console\Output\OutputInterface;
4
5
/**
6
 * Class HostsPluginChecker
7
 * @package Magestead\Helper
8
 */
9
class HostsPluginChecker
10
{
11
    /**
12
     * @param array $options
13
     * @param OutputInterface $output
14
     */
15
    public static function verify(array $options, OutputInterface $output)
16
    {
17
        $hostPlugin = `vagrant plugin list | grep vagrant-hostsupdater`;
18
        if (is_null($hostPlugin)) {
19
            self::editHostsInstructions($options, $output);
20
21
            $output->writeln(
22
                '<comment>Installing the vagrant-hostsupdater plugin will remove the need for
23
manual edits of your hosts file.</comment>'
24
            );
25
        }
26
    }
27
28
    /**
29
     * @param array $options
30
     * @param OutputInterface $output
31
     */
32
    protected static function editHostsInstructions(array $options, OutputInterface $output)
33
    {
34
        $output->writeln('<comment>NOTE: You will need to add the following to your hosts file!</comment>');
35
        $comment = $options['vagrantfile']['vm']['network']['private_network'] .
36
            ' ' . $options['magestead']['apps']['mba_12345']['base_url'];
37
        $output->writeln('<info>' . $comment . '</info>');
38
    }
39
}