Completed
Push — 8.x ( c18498...4d845b )
by Tim
08:43
created

SimpleConfigurationLoader::getEditionMapping()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 37
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 17
nc 3
nop 1
dl 0
loc 37
ccs 0
cts 18
cp 0
crap 12
rs 9.7
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * TechDivision\Import\Cli\SimpleConfigurationLoader
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2016 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/techdivision/import-cli-simple
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Cli;
22
23
use Symfony\Component\Console\Input\InputInterface;
24
use Symfony\Component\DependencyInjection\ContainerInterface;
25
use TechDivision\Import\ConfigurationFactoryInterface;
26
use TechDivision\Import\Cli\Command\InputOptionKeys;
27
use TechDivision\Import\Cli\Configuration\LibraryLoader;
28
use TechDivision\Import\Cli\Utils\DependencyInjectionKeys;
29
use TechDivision\Import\Cli\Utils\MagentoConfigurationKeys;
30
use TechDivision\Import\Utils\CommandNames;
31
use TechDivision\Import\Utils\Mappings\CommandNameToEntityTypeCode;
32
use TechDivision\Import\ConsoleOptionLoaderInterface;
33
34
/**
35
 * The configuration loader implementation.
36
 *
37
 * @author    Tim Wagner <[email protected]>
38
 * @copyright 2016 TechDivision GmbH <[email protected]>
39
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
40
 * @link      https://github.com/techdivision/import-cli-simple
41
 * @link      http://www.techdivision.com
42
 */
43
class SimpleConfigurationLoader implements ConfigurationLoaderInterface
44
{
45
46
    /**
47
     * The key for the Magento Edition in the metadata extracted from the Composer configuration.
48
     *
49
     * @var string
50
     */
51
    const EDITION = 'edition';
52
53
    /**
54
     * The key for the Magento Version in the metadata extracted from the Composer configuration.
55
     *
56
     * @var string
57
     */
58
    const VERSION = 'version';
59
60
    /**
61
     * The container instance.
62
     *
63
     * @var \Symfony\Component\DependencyInjection\ContainerInterface
64
     */
65
    protected $container;
66
67
    /**
68
     * The actual input instance.
69
     *
70
     * @var \Symfony\Component\Console\Input\InputInterface
71
     */
72
    protected $input;
73
74
    /**
75
     * The library loader instance.
76
     *
77
     * @param \TechDivision\Import\Cli\LibraryLoader
78
     */
79
    protected $libraryLoader;
80
81
    /**
82
     * The configuration factory instance.
83
     *
84
     * @var \TechDivision\Import\ConfigurationFactoryInterface
85
     */
86
    protected $configurationFactory;
87
88
    /**
89
     * The available command names.
90
     *
91
     * @var \TechDivision\Import\Utils\CommandNames
92
     */
93
    protected $commandNames;
94
95
    /**
96
     * The mapping of the command names to the entity type codes
97
     *
98
     * @var \TechDivision\Import\Utils\Mappings\CommandNameToEntityTypeCode
99
     */
100
    protected $commandNameToEntityTypeCode;
101
102
    /**
103
     * The console option loader instance.
104
     *
105
     * @var \TechDivision\Import\ConsoleOptionLoaderInterface
106
     */
107
    protected $consoleOptionLoader;
108
109
    /**
110
     * Initializes the configuration loader.
111
     *
112
     * @param \Symfony\Component\Console\Input\InputInterface                 $input                        The input instance
113
     * @param \Symfony\Component\DependencyInjection\ContainerInterface       $container                    The container instance
114
     * @param \TechDivision\Import\Cli\Configuration\LibraryLoader            $libraryLoader                The configuration loader instance
115
     * @param \TechDivision\Import\ConfigurationFactoryInterface              $configurationFactory         The configuration factory instance
116
     * @param \TechDivision\Import\Utils\CommandNames                         $commandNames                 The available command names
117
     * @param \TechDivision\Import\Utils\Mappings\CommandNameToEntityTypeCode $commandNameToEntityTypeCodes The mapping of the command names to the entity type codes
118
     * @param \TechDivision\Import\ConsoleOptionLoaderInterface               $consoleOptionLoader          The console option loader instance
119
     */
120
    public function __construct(
121
        InputInterface $input,
122
        ContainerInterface $container,
123
        LibraryLoader $libraryLoader,
124
        ConfigurationFactoryInterface $configurationFactory,
125
        CommandNames $commandNames,
126
        CommandNameToEntityTypeCode $commandNameToEntityTypeCodes,
127
        ConsoleOptionLoaderInterface $consoleOptionLoader
128
    ) {
129
130
        // set the passed instances
131
        $this->input = $input;
132
        $this->container = $container;
133
        $this->libraryLoader = $libraryLoader;
134
        $this->configurationFactory = $configurationFactory;
135
        $this->commandNames = $commandNames;
136
        $this->commandNameToEntityTypeCode = $commandNameToEntityTypeCodes;
137
        $this->consoleOptionLoader = $consoleOptionLoader;
138
    }
139
140
    /**
141
     * Factory implementation to create a new initialized configuration instance.
142
     *
143
     * If command line options are specified, they will always override the
144
     * values found in the configuration file.
145
     *
146
     * @return \TechDivision\Import\ConfigurationInterface The configuration instance
147
     */
148
    public function load()
149
    {
150
151
        // initially try to create the configuration instance
152
        $instance = $this->createInstance();
153
154
        // we have to set the entity type code at least
155
        $instance->setEntityTypeCode($this->getEntityTypeCode());
156
157
        // load and merge the console options
158
        $this->getConsoleOptionLoader()->load($instance);
159
160
        // return the initialized configuration instance
161
        return $instance;
162
    }
163
164
    /**
165
     * This method create the configuration instance from the configuration file
166
     * defined by the commandline args and options.
167
     *
168
     * @return \TechDivision\Import\ConfigurationInterface The configuration instance loaded from the configuration file
169
     * @throws \Exception Is thrown, if the specified configuration file doesn't exist or the mandatory arguments/options to run the requested operation are not available
170
     */
171
    protected function createInstance()
172
    {
173
174
        // load the actual vendor directory and entity type code
175
        $vendorDir = $this->getVendorDir();
176
177
        // the path of the JMS serializer directory, relative to the vendor directory
178
        $jmsDir = DIRECTORY_SEPARATOR . 'jms' . DIRECTORY_SEPARATOR . 'serializer' . DIRECTORY_SEPARATOR . 'src';
179
180
        // try to find the path to the JMS Serializer annotations
181
        if (!file_exists($annotationDir = $vendorDir . DIRECTORY_SEPARATOR . $jmsDir)) {
182
            // stop processing, if the JMS annotations can't be found
183
            throw new \Exception(
184
                sprintf(
185
                    'The jms/serializer libarary can not be found in one of "%s"',
186
                    implode(', ', $vendorDir)
0 ignored issues
show
Bug introduced by
$vendorDir of type string is incompatible with the type array expected by parameter $pieces of implode(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

186
                    implode(', ', /** @scrutinizer ignore-type */ $vendorDir)
Loading history...
187
                )
188
            );
189
        }
190
191
        // register the autoloader for the JMS serializer annotations
192
        \Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace(
0 ignored issues
show
Deprecated Code introduced by
The function Doctrine\Common\Annotati...sterAutoloadNamespace() has been deprecated: this method is deprecated and will be removed in doctrine/annotations 2.0 autoloading should be deferred to the globally registered autoloader by then. For now, use @example AnnotationRegistry::registerLoader('class_exists') ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

192
        /** @scrutinizer ignore-deprecated */ \Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace(

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
193
            'JMS\Serializer\Annotation',
194
            $annotationDir
195
        );
196
197
        // query whether or not, a configuration file has been specified
198
        if ($configuration = $this->input->getOption(InputOptionKeys::CONFIGURATION)) {
199
            // load the configuration from the file with the given filename
200
            $instance = $this->createConfiguration($configuration);
201
            // set the actual command name in the configuration
202
            $instance->setCommandName($this->input->getFirstArgument());
203
            // return the instance
204
            return $instance;
205
        } elseif (($magentoEdition = $this->input->getOption(InputOptionKeys::MAGENTO_EDITION)) && ($magentoVersion = $this->input->getOption(InputOptionKeys::MAGENTO_VERSION))) {
206
            // use the Magento Edition that has been specified as option
207
            $instance = $this->createConfiguration();
208
209
            // override the Magento Edition/Version
210
            $instance->setMagentoEdition($magentoEdition);
211
            $instance->setMagentoVersion($magentoVersion);
212
213
            // set the actual command name in the configuration
214
            $instance->setCommandName($this->input->getFirstArgument());
215
216
            // return the instance
217
            return $instance;
218
        }
219
220
        // finally, query whether or not the installation directory is a valid Magento root directory
221
        if (!$this->isMagentoRootDir($installationDir = $this->input->getOption(InputOptionKeys::INSTALLATION_DIR))) {
0 ignored issues
show
Bug introduced by
It seems like $installationDir = $this...Keys::INSTALLATION_DIR) can also be of type string[]; however, parameter $dir of TechDivision\Import\Cli\...der::isMagentoRootDir() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

221
        if (!$this->isMagentoRootDir(/** @scrutinizer ignore-type */ $installationDir = $this->input->getOption(InputOptionKeys::INSTALLATION_DIR))) {
Loading history...
222
            throw new \Exception(
223
                sprintf(
224
                    'Directory "%s" is not a valid Magento root directory, please use option "--installation-dir" to specify it',
225
                    $installationDir
0 ignored issues
show
Bug introduced by
It seems like $installationDir can also be of type string[]; however, parameter $args of sprintf() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

225
                    /** @scrutinizer ignore-type */ $installationDir
Loading history...
226
                )
227
            );
228
        }
229
230
        // use the Magento Edition that has been detected by the installation directory
231
        $instance = $this->createConfiguration();
232
233
        // load the Magento Edition from the Composer configuration file
234
        $metadata = $this->getEditionMapping($installationDir);
0 ignored issues
show
Bug introduced by
It seems like $installationDir can also be of type string[]; however, parameter $installationDir of TechDivision\Import\Cli\...er::getEditionMapping() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

234
        $metadata = $this->getEditionMapping(/** @scrutinizer ignore-type */ $installationDir);
Loading history...
235
236
        // extract edition & version from the metadata
237
        $magentoEdition = $metadata[SimpleConfigurationLoader::EDITION];
238
        $magentoVersion = $metadata[SimpleConfigurationLoader::VERSION];
239
240
        // override the Magento Edition/Version
241
        $instance->setMagentoEdition($magentoEdition);
242
        $instance->setMagentoVersion($magentoVersion);
243
244
        // set the actual command name in the configuration
245
        $instance->setCommandName($this->input->getFirstArgument());
246
247
        // return the instance
248
        return $instance;
249
    }
250
251
    /**
252
     * Create and return a new configuration instance from the passed configuration filename
253
     * after merging additional specified params from the commandline.
254
     *
255
     * @param string|null $filename The configuration filename to use
256
     *
257
     * @return \TechDivision\Import\ConfigurationInterface The configuration instance
258
     */
259
    protected function createConfiguration($filename = null)
260
    {
261
262
        // initialize the params specified with the --params parameter
263
        $params = null;
264
265
        // try to load the params from the commandline
266
        if ($this->input->hasOptionSpecified(InputOptionKeys::PARAMS) && $this->input->getOption(InputOptionKeys::PARAMS)) {
0 ignored issues
show
Bug introduced by
The method hasOptionSpecified() does not exist on Symfony\Component\Console\Input\InputInterface. Did you maybe mean hasOption()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

266
        if ($this->input->/** @scrutinizer ignore-call */ hasOptionSpecified(InputOptionKeys::PARAMS) && $this->input->getOption(InputOptionKeys::PARAMS)) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
267
            $params = $this->input->getOption(InputOptionKeys::PARAMS);
268
        }
269
270
        // initialize the params file specified with the --params-file parameter
271
        $paramsFile = null;
272
273
        // try to load the path of the params file from the commandline
274
        if ($this->input->hasOptionSpecified(InputOptionKeys::PARAMS_FILE) && $this->input->getOption(InputOptionKeys::PARAMS_FILE)) {
275
            $paramsFile = $this->input->getOption(InputOptionKeys::PARAMS_FILE);
276
        }
277
278
        // if a filename has been passed, try to load the configuration from the file
279
        if (is_file($filename)) {
280
            return $this->configurationFactory->factory($filename, pathinfo($filename, PATHINFO_EXTENSION), $params, $paramsFile);
0 ignored issues
show
Unused Code introduced by
The call to TechDivision\Import\Conf...oryInterface::factory() has too many arguments starting with $params. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

280
            return $this->configurationFactory->/** @scrutinizer ignore-call */ factory($filename, pathinfo($filename, PATHINFO_EXTENSION), $params, $paramsFile);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
281
        }
282
283
        // initialize the array for the directories
284
        $directories = array();
285
286
        // set the default file format
287
        $format = 'json';
288
289
        // load the actual vendor directory and entity type code
290
        $vendorDir = $this->getVendorDir();
291
292
        // load the default configuration directory from the DI configuration
293
        $defaultConfigurationDirectory = $this->getContainer()->getParameter(DependencyInjectionKeys::APPLICATION_DEFAULT_CONFIGURATION_DIR);
294
295
        // load the directories that has to be parsed for configuration files1
296
        foreach ($this->getDefaultLibraries() as $defaultLibrary) {
297
            // initialize the directory name
298
            $directory = implode(
299
                DIRECTORY_SEPARATOR,
300
                array_merge(
301
                    array($vendorDir),
302
                    explode('/', $defaultLibrary),
303
                    explode('/', $defaultConfigurationDirectory)
304
                )
305
            );
306
307
            // query whether or not the directory is available1
308
            if (is_dir($directory)) {
309
                $directories[] = $directory;
310
            }
311
        }
312
313
        // initialize the default custom configuration directory
314
        $customConfigurationDirectory = implode(
315
            DIRECTORY_SEPARATOR,
316
            array_merge(
317
                array(getcwd()),
318
                explode('/', $this->getContainer()->getParameter(DependencyInjectionKeys::APPLICATION_CUSTOM_CONFIGURATION_DIR))
319
            )
320
        );
321
322
        // query whether or not a custom configuration directory has been speified, if yes override the default one
323
        if ($this->input->hasOptionSpecified(InputOptionKeys::CUSTOM_CONFIGURATION_DIR) && $this->input->getOption(InputOptionKeys::CUSTOM_CONFIGURATION_DIR)) {
324
            $customConfigurationDirectory = $this->input->getOption(InputOptionKeys::CUSTOM_CONFIGURATION_DIR);
325
        }
326
327
        // specify the default directory for custom configuration files
328
        if (is_dir($customConfigurationDirectory)) {
0 ignored issues
show
Bug introduced by
It seems like $customConfigurationDirectory can also be of type string[]; however, parameter $filename of is_dir() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

328
        if (is_dir(/** @scrutinizer ignore-type */ $customConfigurationDirectory)) {
Loading history...
329
            $directories[] = $customConfigurationDirectory;
330
        }
331
332
        // load and return the configuration from the files found in the passed directories
333
        return $this->configurationFactory->factoryFromDirectories($directories, $format, $params, $paramsFile);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->configurat..., $params, $paramsFile) returns the type void which is incompatible with the documented return type TechDivision\Import\ConfigurationInterface.
Loading history...
Bug introduced by
It seems like $paramsFile can also be of type string[]; however, parameter $paramsFile of TechDivision\Import\Conf...actoryFromDirectories() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

333
        return $this->configurationFactory->factoryFromDirectories($directories, $format, $params, /** @scrutinizer ignore-type */ $paramsFile);
Loading history...
Bug introduced by
It seems like $params can also be of type string[]; however, parameter $params of TechDivision\Import\Conf...actoryFromDirectories() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

333
        return $this->configurationFactory->factoryFromDirectories($directories, $format, /** @scrutinizer ignore-type */ $params, $paramsFile);
Loading history...
Bug introduced by
Are you sure the usage of $this->configurationFact..., $params, $paramsFile) targeting TechDivision\Import\Conf...actoryFromDirectories() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
334
    }
335
336
    /**
337
     * Return's the DI container instance.
338
     *
339
     * @return \Symfony\Component\DependencyInjection\ContainerInterface The DI container instance
340
     */
341
    protected function getContainer()
342
    {
343
        return $this->container;
344
    }
345
346
    /**
347
     * The console option loader instance.
348
     *
349
     * @return \TechDivision\Import\ConsoleOptionLoaderInterface The instance
350
     */
351
    protected function getConsoleOptionLoader()
352
    {
353
        return $this->consoleOptionLoader;
354
    }
355
356
    /**
357
     * Return's the absolute path to the actual vendor directory.
358
     *
359
     * @return string The absolute path to the actual vendor directory
360
     * @throws \Exception Is thrown, if none of the possible vendor directories can be found
361
     */
362
    protected function getVendorDir()
363
    {
364
        return $this->getContainer()->getParameter(DependencyInjectionKeys::CONFIGURATION_VENDOR_DIR);
365
    }
366
367
    /**
368
     * Return's the actual command name.
369
     *
370
     * @return string The actual command name
371
     */
372
    protected function getCommandName()
373
    {
374
        return $this->input->getArgument('command');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->input->getArgument('command') also could return the type string[] which is incompatible with the documented return type string.
Loading history...
375
    }
376
377
    /**
378
     * Return's the command's entity type code.
379
     *
380
     * @return string The command's entity type code
381
     * @throws \Exception Is thrown, if the command name can not be mapped
382
     */
383
    protected function getEntityTypeCode()
384
    {
385
386
        // try to map the command name to a entity type code
387
        if (array_key_exists($commandName = $this->getCommandName(), (array) $this->commandNameToEntityTypeCode)) {
388
            return $this->commandNameToEntityTypeCode[$commandName];
389
        }
390
391
        // throw an exception if not possible
392
        throw new \Exception(sprintf('Can\'t map command name %s to a entity type', $commandName));
393
    }
394
395
    /**
396
     * Returns the mapped Magento Edition from the passed Magento installation.
397
     *
398
     * @param string $installationDir The Magento installation directory
399
     *
400
     * @return array The array with the mapped Magento Edition (either CE or EE) + the Version
401
     * @throws \Exception Is thrown, if the passed installation directory doesn't contain a valid Magento installation
402
     */
403
    protected function getEditionMapping($installationDir)
404
    {
405
406
        // load the default edition mappings from the configuration
407
        $editionMappings = $this->getContainer()->getParameter(DependencyInjectionKeys::APPLICATION_EDITION_MAPPINGS);
408
409
        // load the composer file from the Magento root directory
410
        $composer = json_decode(file_get_contents($composerFile = sprintf('%s/composer.json', $installationDir)), true);
411
412
        // try to load and explode the Magento Edition identifier from the Composer name
413
        $explodedEdition = explode('/', $composer[MagentoConfigurationKeys::COMPOSER_EDITION_NAME_ATTRIBUTE]);
414
415
        // try to load and explode the Magento Edition from the Composer configuration
416
        if (!isset($editionMappings[$possibleEdition = end($explodedEdition)])) {
417
            throw new \Exception(
418
                sprintf(
419
                    '"%s" detected in "%s" is not a valid Magento Edition, please set Magento Edition with the "--magento-edition" option',
420
                    $possibleEdition,
421
                    $composerFile
422
                )
423
            );
424
        }
425
426
        // try to load and explode the Magento Version from the Composer configuration
427
        if (!isset($composer[MagentoConfigurationKeys::COMPOSER_EDITION_VERSION_ATTRIBUTE])) {
428
            throw new \Exception(
429
                sprintf(
430
                    'Can\'t detect a version in "%s", please set Magento Version with the "--magento-version" option',
431
                    $composerFile
432
                )
433
            );
434
        }
435
436
        // return the array with the Magento Version/Edition data
437
        return array(
438
            SimpleConfigurationLoader::VERSION => $composer[MagentoConfigurationKeys::COMPOSER_EDITION_VERSION_ATTRIBUTE],
439
            SimpleConfigurationLoader::EDITION => $editionMappings[$possibleEdition]
440
        );
441
    }
442
443
444
    /**
445
     * Return's the application's default libraries.
446
     *
447
     * @return array The default libraries
448
     */
449
    protected function getDefaultLibraries()
450
    {
451
452
        // load the default libraries from the configuration
453
        $defaultLibraries = $this->getContainer()->getParameter(DependencyInjectionKeys::APPLICATION_DEFAULT_LIBRARIES);
454
455
        // initialize the array for the libraries
456
        $libraries = array();
457
458
        // append each library only ONCE
459
        foreach ($defaultLibraries as $libraries) {
460
            foreach ($libraries as $library) {
461
                if (in_array($library, $libraries)) {
462
                    continue;
463
                }
464
                // append the library
465
                $libraries[] = $library;
466
            }
467
        }
468
469
        // return the array with the libraries
470
        return $libraries;
471
    }
472
473
    /**
474
     * Query whether or not, the passed directory is a Magento root directory.
475
     *
476
     * @param string $dir The directory to query
477
     *
478
     * @return boolean TRUE if the directory is a Magento root directory, else FALSE
479
     */
480
    protected function isMagentoRootDir($dir)
481
    {
482
        return is_file($this->getMagentoEnv($dir));
483
    }
484
485
    /**
486
     * Return's the path to the Magento file with the environment configuration.
487
     *
488
     * @param string $dir The path to the Magento root directory
489
     *
490
     * @return string The path to the Magento file with the environment configuration
491
     */
492
    protected function getMagentoEnv($dir)
493
    {
494
        return sprintf('%s/app/etc/env.php', $dir);
495
    }
496
}
497