Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Testwork / ApplicationFactory.php
1 <?php
2
3 /*
4  * This file is part of the Behat Testwork.
5  * (c) Konstantin Kudryashov <ever.zet@gmail.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 namespace Behat\Testwork;
12
13 use Behat\Testwork\Cli\Application;
14 use Behat\Testwork\ServiceContainer\Configuration\ConfigurationLoader;
15 use Behat\Testwork\ServiceContainer\Extension;
16 use Behat\Testwork\ServiceContainer\ExtensionManager;
17
18 /**
19  * Defines the way application is created.
20  *
21  * Extend and implement this class to create an entry point for your framework.
22  *
23  * @author Konstantin Kudryashov <ever.zet@gmail.com>
24  */
25 abstract class ApplicationFactory
26 {
27     /**
28      * Returns application name.
29      *
30      * @return string
31      */
32     abstract protected function getName();
33
34     /**
35      * Returns current application version.
36      *
37      * @return string
38      */
39     abstract protected function getVersion();
40
41     /**
42      * Returns list of extensions enabled by default.
43      *
44      * @return Extension[]
45      */
46     abstract protected function getDefaultExtensions();
47
48     /**
49      * Returns the name of configuration environment variable.
50      *
51      * @return string
52      */
53     abstract protected function getEnvironmentVariableName();
54
55     /**
56      * Returns user config path.
57      *
58      * @return null|string
59      */
60     abstract protected function getConfigPath();
61
62     /**
63      * Creates application instance.
64      *
65      * @return Application
66      */
67     public function createApplication()
68     {
69         $configurationLoader = $this->createConfigurationLoader();
70         $extensionManager = $this->createExtensionManager();
71
72         return new Application($this->getName(), $this->getVersion(), $configurationLoader, $extensionManager);
73     }
74
75     /**
76      * Creates configuration loader.
77      *
78      * @return ConfigurationLoader
79      */
80     protected function createConfigurationLoader()
81     {
82         return new ConfigurationLoader($this->getEnvironmentVariableName(), $this->getConfigPath());
83     }
84
85     /**
86      * Creates extension manager.
87      *
88      * @return ExtensionManager
89      */
90     protected function createExtensionManager()
91     {
92         return new ExtensionManager($this->getDefaultExtensions());
93     }
94 }