Completed
Pull Request — master (#14)
by
unknown
02:15
created
code/MultiDomainDomain.php 1 patch
Spacing   +16 added lines, -17 removed lines patch added patch discarded remove patch
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
 		$this->hostname = $config['hostname'];
51 51
 		$this->url = isset($config['resolves_to']) ? $config['resolves_to'] : null;
52 52
 
53
-		$globalAllowed = (array) Config::inst()->get('MultiDomain','allow');
54
-		$globalForced = (array) Config::inst()->get('MultiDomain','force');
55
-		$myAllowed = isset($config['allow']) ? $config['allow'] : array ();
56
-		$myForced = isset($config['force']) ? $config['force'] : array ();
53
+		$globalAllowed = (array) Config::inst()->get('MultiDomain', 'allow');
54
+		$globalForced = (array) Config::inst()->get('MultiDomain', 'force');
55
+		$myAllowed = isset($config['allow']) ? $config['allow'] : array();
56
+		$myForced = isset($config['force']) ? $config['force'] : array();
57 57
 		$this->allowedPaths = array_merge($globalAllowed, $myAllowed);
58 58
 		$this->forcedPaths = array_merge($globalForced, $myForced);
59 59
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	 * @return boolean
82 82
 	 */
83 83
 	public function isActive() {
84
-		if($this->isAllowedPath($_SERVER['REQUEST_URI'])) {
84
+		if ($this->isAllowedPath($_SERVER['REQUEST_URI'])) {
85 85
 			return false;
86 86
 		}
87 87
 
@@ -90,8 +90,7 @@  discard block
 block discarded – undo
90 90
 		$hostname = $this->getHostname();
91 91
 
92 92
 		return $allow_subdomains ?
93
-					preg_match('/(\.|^)'.$hostname.'$/', $current_host) :
94
-					($current_host == $hostname);
93
+					preg_match('/(\.|^)'.$hostname.'$/', $current_host) : ($current_host == $hostname);
95 94
 	}
96 95
 
97 96
 	/**
@@ -110,11 +109,11 @@  discard block
 block discarded – undo
110 109
 	 * @return string
111 110
 	 */
112 111
 	public function getNativeURL($url) {
113
-		if($this->isPrimary()) {
112
+		if ($this->isPrimary()) {
114 113
 			throw new Exception("Cannot convert a native URL on the primary domain");
115 114
 		}
116 115
 
117
-		if($this->isAllowedPath($url) || $this->isForcedPath($url)) {
116
+		if ($this->isAllowedPath($url) || $this->isForcedPath($url)) {
118 117
 			return $url;
119 118
 		}
120 119
 
@@ -129,7 +128,7 @@  discard block
 block discarded – undo
129 128
 	 * @return string
130 129
 	 */
131 130
 	public function getVanityURL($url) {
132
-		if($this->isPrimary() || $this->isAllowedPath($url)) {
131
+		if ($this->isPrimary() || $this->isAllowedPath($url)) {
133 132
 			return $url;
134 133
 		}
135 134
 
@@ -142,9 +141,9 @@  discard block
 block discarded – undo
142 141
 	 * @return boolean
143 142
 	 */
144 143
 	public function hasURL($url) {
145
-		if($this->isForcedPath($url)) return true;
146
-		$domainBaseURL = trim($this->getURL(),'/');
147
-		if(preg_match('/^'.$domainBaseURL.'/', $url)) {
144
+		if ($this->isForcedPath($url)) return true;
145
+		$domainBaseURL = trim($this->getURL(), '/');
146
+		if (preg_match('/^'.$domainBaseURL.'/', $url)) {
148 147
 			return true;
149 148
 		}
150 149
 
@@ -176,13 +175,13 @@  discard block
 block discarded – undo
176 175
 	 * @return boolean
177 176
 	 */
178 177
 	protected static function match_url($url, $patterns) {
179
-		if(!is_array($patterns)) return false;
178
+		if (!is_array($patterns)) return false;
180 179
 
181 180
 		$url = ltrim($url, '/');
182
-		if(substr($url, -1) !== '/') $url .= '/';
181
+		if (substr($url, -1) !== '/') $url .= '/';
183 182
 
184
-		foreach($patterns as $pattern) {
185
-			if(fnmatch($pattern, $url)) return true;
183
+		foreach ($patterns as $pattern) {
184
+			if (fnmatch($pattern, $url)) return true;
186 185
 		}
187 186
 
188 187
 		return false;
Please login to merge, or discard this patch.