Code Duplication    Length = 75-77 lines in 3 locations

src/AppserverIo/Server/Traits/EnvVarsObjectTrait.php 1 location

@@ 32-106 (lines=75) @@
29
 * @link      https://github.com/appserver-io/server
30
 * @link      http://www.appserver.io
31
 */
32
trait EnvVarsObjectTrait
33
{
34
    /**
35
     * Sets a value to specific env var
36
     *
37
     * @param string $envVar The env var to set
38
     * @param string $value  The value to env var
39
     *
40
     * @return void
41
     */
42
    public function setEnvVar($envVar, $value)
43
    {
44
        $this->envVars->add($envVar, $value);
45
    }
46
47
    /**
48
     * Unsets a specific env var
49
     *
50
     * @param string $envVar The env var to unset
51
     *
52
     * @return void
53
     */
54
    public function unsetEnvVar($envVar)
55
    {
56
        $this->envVars->remove($envVar);
57
    }
58
59
    /**
60
     * Returns a value for specific env var
61
     *
62
     * @param string $envVar The env var to get value for
63
     *
64
     * @throws \AppserverIo\Server\Exceptions\ServerException
65
     *
66
     * @return mixed The value to given env var
67
     */
68
    public function getEnvVar($envVar)
69
    {
70
        // get from hash map
71
        return $this->envVars->get($envVar);
72
    }
73
74
    /**
75
     * Returns all the env vars as array key value pair format
76
     *
77
     * @return array The env vars as array
78
     */
79
    public function getEnvVars()
80
    {
81
        return $this->envVars->toIndexedArray();
82
    }
83
84
    /**
85
     * Checks if value exists for given env var
86
     *
87
     * @param string $envVar The env var to check
88
     *
89
     * @return boolean Weather it has envVar (true) or not (false)
90
     */
91
    public function hasEnvVar($envVar)
92
    {
93
        // check if var is set
94
        return $this->envVars->exists($envVar);
95
    }
96
97
    /**
98
     * Clears the env vars storage
99
     *
100
     * @return void
101
     */
102
    public function clearEnvVars()
103
    {
104
        $this->envVars->clear();
105
    }
106
}
107

src/AppserverIo/Server/Traits/ModuleVarsObjectTrait.php 1 location

@@ 32-108 (lines=77) @@
29
 * @link      https://github.com/appserver-io/server
30
 * @link      http://www.appserver.io
31
 */
32
trait ModuleVarsObjectTrait
33
{
34
35
    /**
36
     * Sets a value to specific module var
37
     *
38
     * @param string $moduleVar The module var to set
39
     * @param string $value     The value to module var
40
     *
41
     * @return void
42
     */
43
    public function setModuleVar($moduleVar, $value)
44
    {
45
        $this->moduleVars->add($moduleVar, $value);
46
    }
47
48
    /**
49
     * Unsets a specific module var
50
     *
51
     * @param string $moduleVar The module var to unset
52
     *
53
     * @return void
54
     */
55
    public function unsetModuleVar($moduleVar)
56
    {
57
        $this->moduleVars->remove($moduleVar);
58
    }
59
60
    /**
61
     * Returns a value for specific module var
62
     *
63
     * @param string $moduleVar The module var to get value for
64
     *
65
     * @throws \AppserverIo\Server\Exceptions\ServerException
66
     *
67
     * @return mixed The value to given module var
68
     */
69
    public function getModuleVar($moduleVar)
70
    {
71
        // get from hash map
72
        return $this->moduleVars->get($moduleVar);
73
    }
74
75
76
    /**
77
     * Returns all the module vars as array key value pair format
78
     *
79
     * @return array The module vars as array
80
     */
81
    public function getModuleVars()
82
    {
83
        return $this->moduleVars->toIndexedArray();
84
    }
85
86
    /**
87
     * Checks if value exists for given module var
88
     *
89
     * @param string $moduleVar The module var to check
90
     *
91
     * @return boolean Weather it has moduleVar (true) or not (false)
92
     */
93
    public function hasModuleVar($moduleVar)
94
    {
95
        // check if var is set
96
        return $this->moduleVars->exists($moduleVar);
97
    }
98
99
    /**
100
     * Clears the module vars storage
101
     *
102
     * @return void
103
     */
104
    public function clearModuleVars()
105
    {
106
        $this->moduleVars->clear();
107
    }
108
}
109

src/AppserverIo/Server/Traits/ServerVarsObjectTrait.php 1 location

@@ 32-106 (lines=75) @@
29
 * @link      https://github.com/appserver-io/server
30
 * @link      http://www.appserver.io
31
 */
32
trait ServerVarsObjectTrait
33
{
34
    /**
35
     * Sets a value to specific server var
36
     *
37
     * @param string $serverVar The server var to set
38
     * @param string $value     The value to server var
39
     *
40
     * @return void
41
     */
42
    public function setServerVar($serverVar, $value)
43
    {
44
        $this->serverVars->add($serverVar, $value);
45
    }
46
47
    /**
48
     * Unsets a specific server var
49
     *
50
     * @param string $serverVar The server var to unset
51
     *
52
     * @return void
53
     */
54
    public function unsetServerVar($serverVar)
55
    {
56
        $this->serverVars->remove($serverVar);
57
    }
58
59
    /**
60
     * Returns a value for specific server var
61
     *
62
     * @param string $serverVar The server var to get value for
63
     *
64
     * @throws \AppserverIo\Server\Exceptions\ServerException
65
     *
66
     * @return string The value to given server var
67
     */
68
    public function getServerVar($serverVar)
69
    {
70
        // get from hash map
71
        return $this->serverVars->get($serverVar);
72
    }
73
74
    /**
75
     * Returns all the server vars as array key value pair format
76
     *
77
     * @return array The server vars as array
78
     */
79
    public function getServerVars()
80
    {
81
        return $this->serverVars->toIndexedArray();
82
    }
83
84
    /**
85
     * Checks if value exists for given server var
86
     *
87
     * @param string $serverVar The server var to check
88
     *
89
     * @return bool Weather it has serverVar (true) or not (false)
90
     */
91
    public function hasServerVar($serverVar)
92
    {
93
        // check if server var is set
94
        return $this->serverVars->exists($serverVar);
95
    }
96
97
    /**
98
     * Clears the server vars storage
99
     *
100
     * @return void
101
     */
102
    public function clearServerVars()
103
    {
104
        $this->serverVars->clear();
105
    }
106
}
107