Completed
Pull Request — epic/2.0.0 (#37)
by Steven
03:03
created

Options::setMagento2Settings()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 1
Metric Value
c 1
b 1
f 1
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 3
1
<?php namespace Magestead\Helper;
2
3
use Symfony\Component\Console\Question\Question;
4
use Symfony\Component\Console\Input\InputInterface;
5
use Symfony\Component\Console\Output\OutputInterface;
6
use Symfony\Component\Console\Question\ChoiceQuestion;
7
use Symfony\Component\Console\Question\ConfirmationQuestion;
8
9
/**
10
 * Class Options
11
 * @package Magestead\Helper
12
 */
13
class Options
14
{
15
    const BOX_PREFIX = 'richdynamix/magestead-';
16
    protected $_app = 'magento2';
0 ignored issues
show
Coding Style introduced by
$_app does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
17
    protected $_server;
0 ignored issues
show
Coding Style introduced by
$_server does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
18
    protected $_phpVer = '56';
0 ignored issues
show
Coding Style introduced by
$_phpVer does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
19
    protected $_os = 'centos65';
0 ignored issues
show
Coding Style introduced by
$_os does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
20
    protected $_box;
0 ignored issues
show
Coding Style introduced by
$_box does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
21
    protected $_m2Username;
0 ignored issues
show
Coding Style introduced by
$_m2Username does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
22
    protected $_m2Password;
0 ignored issues
show
Coding Style introduced by
$_m2Password does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
23
    protected $_ipAddress;
0 ignored issues
show
Coding Style introduced by
$_ipAddress does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
24
    protected $_memorylimit;
0 ignored issues
show
Coding Style introduced by
$_memorylimit does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
25
    protected $_cpus;
0 ignored issues
show
Coding Style introduced by
$_cpus does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
26
    protected $_locale;
0 ignored issues
show
Coding Style introduced by
$_locale does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
27
    protected $_currency;
0 ignored issues
show
Coding Style introduced by
$_currency does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
28
    protected $_baseUrl;
0 ignored issues
show
Coding Style introduced by
$_baseUrl does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
29
    protected $_repoUrl = '';
0 ignored issues
show
Coding Style introduced by
$_repoUrl does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
30
31
    /**
32
     * Options constructor.
33
     * @param $helper
34
     * @param InputInterface $input
35
     * @param OutputInterface $output
36
     */
37
    public function __construct($helper, InputInterface $input, OutputInterface $output)
38
    {
39
        $this->setVagrantSettings($helper, $input, $output);
40
41
        $this->setServerConfig($helper, $input, $output);
42
43
        $this->setApplicationSettings($helper, $input, $output);
44
        $this->setMagento2Settings($helper, $input, $output);
45
        $this->setVersionControlSettings($helper, $input, $output);
46
47
        $this->setVagrantBox();
48
49
    }
50
    /**
51
     * @return array
52
     */
53
    public function getAllOptions()
54
    {
55
        return [
56
          'app' => $this->_app,
57
          'server' => $this->_server,
58
          'phpver' => $this->_phpVer,
59
          'os' => $this->_os,
60
          'box' => $this->_box,
61
          'm2user' => $this->_m2Username,
62
          'm2pass' => $this->_m2Password,
63
          'repo_url' => $this->_repoUrl,
64
          'ip_address' => $this->_ipAddress,
65
          'cpus' => $this->_cpus,
66
          'memory_limit' => $this->_memorylimit,
67
          'locale' => $this->_locale,
68
          'default_currency' => $this->_currency,
69
          'base_url' => $this->_baseUrl,
70
        ];
71
    }
72
73
    /**
74
     * @param $helper
75
     * @param InputInterface $input
76
     * @param OutputInterface $output
77
     */
78
    protected function setVagrantSettings($helper, InputInterface $input, OutputInterface $output)
79
    {
80
        $output->writeln('<comment>Lets configure your project\'s VM</comment>');
81
82
        $ipQuestion = new Question("Configure the IP for your VM (192.168.47.47): ", '192.168.47.47');
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
Coding Style Comprehensibility introduced by
The string literal Configure the IP for your VM (192.168.47.47): does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
83
        $this->_ipAddress = strtolower($helper->ask($input, $output, $ipQuestion));
84
85
        $cpuQuestion = new Question("How many CPU's would you like to use? (1): ", '1');
86
        $this->_cpus = strtolower($helper->ask($input, $output, $cpuQuestion));
87
88
        $memoryQuestion = new Question("Define the VM memory limit (2048): ", '2048');
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
Coding Style Comprehensibility introduced by
The string literal Define the VM memory limit (2048): does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
89
        $this->_memorylimit = strtolower($helper->ask($input, $output, $memoryQuestion));
90
    }
91
92
    /**
93
     * @param $helper
94
     * @param InputInterface $input
95
     * @param OutputInterface $output
96
     */
97
    protected function setApplicationSettings($helper, InputInterface $input, OutputInterface $output)
98
    {
99
        $output->writeln('<comment>Lets configure your project\'s application</comment>');
100
        if ($this->_phpVer !== '70') {
101
            $appQuestion = new ChoiceQuestion(
102
                "Which application do you want to install?",
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Which application do you want to install? does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
103
                ['Magento', 'Magento 2'],
104
                0
105
            );
106
107
            $this->_app = strtolower($helper->ask($input, $output, $appQuestion));
108
        }
109
        $baseUrlQuestion = new Question("Enter your application's base_url (magestead.dev): ", 'magestead.dev');
110
        $this->_baseUrl = strtolower($helper->ask($input, $output, $baseUrlQuestion));
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
111
112
        $currenyQuestion = new Question("Enter your application's default currency (GBP): ", 'GBP');
113
        $this->_currency = $helper->ask($input, $output, $currenyQuestion);
114
115
        $localeQuestion = new Question("Enter your application's default locale (en_GB): ", 'en_GB');
116
        $this->_locale = $helper->ask($input, $output, $localeQuestion);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
117
    }
118
119
    /**
120
     * @param $helper
121
     * @param InputInterface $input
122
     * @param OutputInterface $output
123
     * @return bool
0 ignored issues
show
Documentation introduced by
Should the return type not be boolean|integer?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
124
     */
125
    protected function setMagento2Settings($helper, InputInterface $input, OutputInterface $output)
126
    {
127
        if ($this->_app === 'magento2') {
128
            return $this->verifyAuth($helper, $input, $output);
129
        }
130
131
        return true;
132
    }
133
134
    /**
135
     * @param $helper
136
     * @param InputInterface $input
137
     * @param OutputInterface $output
138
     */
139
    protected function setVersionControlSettings($helper, InputInterface $input, OutputInterface $output)
140
    {
141
        $versionControl = new ConfirmationQuestion("Would you like to add your project to GIT? (no/yes) ", false);
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Would you like to add yo...oject to GIT? (no/yes) does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
142
        $versioning = $helper->ask($input, $output, $versionControl);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
143
        if ($versioning) {
144
            $repoQuestion = new Question("Enter your full GitHub/BitBucket repo URL: ", '');
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
Coding Style Comprehensibility introduced by
The string literal Enter your full GitHub/BitBucket repo URL: does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
145
            $this->_repoUrl = strtolower($helper->ask($input, $output, $repoQuestion));
146
        }
147
    }
148
149
    /**
150
     * @param $helper
151
     * @param InputInterface $input
152
     * @param OutputInterface $output
153
     */
154
    protected function askForAuth($helper, InputInterface $input, OutputInterface $output)
155
    {
156
        $username = new Question("Please enter your Magento username (public key): ", '');
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 10 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
Coding Style Comprehensibility introduced by
The string literal Please enter your Magento username (public key): does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
157
        $this->_m2Username = $helper->ask($input, $output, $username);
158
159
        $password = new Question("Please enter your Magento password (private key): ", '');
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 10 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
Coding Style Comprehensibility introduced by
The string literal Please enter your Magento password (private key): does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
160
        $this->_m2Password = $helper->ask($input, $output, $password);
161
    }
162
163
    /**
164
     * @param $helper
165
     * @param InputInterface $input
166
     * @param OutputInterface $output
167
     * @return bool
0 ignored issues
show
Documentation introduced by
Should the return type not be boolean|integer?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
168
     */
169
    protected function verifyAuth($helper, InputInterface $input, OutputInterface $output)
0 ignored issues
show
Coding Style introduced by
verifyAuth uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
170
    {
171
        $authFile = $_SERVER['HOME'] . "/.composer/auth.json";
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal /.composer/auth.json does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
172
173
        $authObj = [];
174
        if (file_exists($authFile)) {
175
            $authJson = file_get_contents($authFile);
176
            $authObj = (array)json_decode($authJson);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
177
178
            if (isset($authObj['http-basic']) && isset($authObj['http-basic']->{'repo.magento.com'})) {
179
                return true;
180
            }
181
        }
182
183
        $this->askForAuth($helper, $input, $output);
184
185
        $authObj['http-basic']['repo.magento.com']['username'] = $this->_m2Username;
186
        $authObj['http-basic']['repo.magento.com']['password'] = $this->_m2Password;
187
188
        $authJson = json_encode($authObj);
189
        return file_put_contents($authFile, $authJson);
190
    }
191
192
    /**
193
     * @param $helper
194
     * @param InputInterface $input
195
     * @param OutputInterface $output
196
     */
197
    protected function setPhp($helper, InputInterface $input, OutputInterface $output)
198
    {
199
        $output->writeln('<info>Keep in mind PHP7 is only available for Magento 2</info>');
200
        $phpVerQuestion = new ChoiceQuestion(
201
            "Which version of PHP should be installed?",
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Which version of PHP should be installed? does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
202
            ['56', '70'],
203
            0
204
        );
205
206
        $this->_phpVer = $helper->ask($input, $output, $phpVerQuestion);
207
    }
208
209
    /**
210
     * Set box name from concat user options
211
     */
212
    protected function setVagrantBox()
213
    {
214
        $this->_box = self::BOX_PREFIX . $this->_os . "-$this->_server-php$this->_phpVer";
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $this instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
215
    }
216
217
    /**
218
     * @param $helper
219
     * @param InputInterface $input
220
     * @param OutputInterface $output
221
     */
222
    protected function setServerConfig($helper, InputInterface $input, OutputInterface $output)
223
    {
224
        $output->writeln('<comment>Lets configure your server</comment>');
225
        $this->setOperatingSystem($helper, $input, $output);
226
        $this->setWebServer($helper, $input, $output);
227
        $this->setPhp($helper, $input, $output);
228
    }
229
230
    /**
231
     * @param $helper
232
     * @param InputInterface $input
233
     * @param OutputInterface $output
234
     */
235
    protected function setWebServer($helper, InputInterface $input, OutputInterface $output)
236
    {
237
        $serverQuestion = new ChoiceQuestion(
238
            "Which webserver would you like?",
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Which webserver would you like? does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
239
            ['NGINX', 'Apache'],
240
            0
241
        );
242
        $this->_server = strtolower($helper->ask($input, $output, $serverQuestion));
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
243
    }
244
245
    /**
246
     * @param $helper
247
     * @param InputInterface $input
248
     * @param OutputInterface $output
249
     */
250
    protected function setOperatingSystem($helper, InputInterface $input, OutputInterface $output)
251
    {
252
        $osQuestion = new ChoiceQuestion(
253
            "Which OS would you like to install?",
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Which OS would you like to install? does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
254
            ['CentOS 6.5', 'Ubuntu 14'],
255
            0
256
        );
257
        $this->_os = str_replace(' ', '', str_replace('.', '', strtolower($helper->ask($input, $output, $osQuestion))));
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
258
    }
259
}