Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Reduce some code complexity.

  • Loading branch information...
commit feda6e06a0f4041427a1d924788a2712cc0e074b 1 parent e58c93c
@markstory markstory authored
View
18 lib/Cake/Error/ExceptionRenderer.php
@@ -102,10 +102,7 @@ public function __construct(Exception $exception) {
if ($exception instanceof CakeException && !$methodExists) {
$method = '_cakeError';
- if (empty($template)) {
- $template = 'error500';
- }
- if ($template == 'internalError') {
+ if (empty($template) || $template == 'internalError') {
$template = 'error500';
}
} elseif ($exception instanceof PDOException) {
@@ -119,13 +116,12 @@ public function __construct(Exception $exception) {
}
}
- if (Configure::read('debug') == 0) {
- if ($method == '_cakeError') {
- $method = 'error400';
- }
- if ($code == 500) {
- $method = 'error500';
- }
+ $isDebug = (Configure::read('debug') == 0);
@dereuromark Collaborator

better $isDebug = !Configure::read('debug') ; - but isnt the variable wrong now? it should probably be $isNotDebug = !Configure::read('debug') ; - or the positive one and if (!$isDebug) checks

@markstory Owner

True, I'll update it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ if ($isDebug && $method == '_cakeError') {
+ $method = 'error400';
+ }
+ if ($isDebug && $code == 500) {
+ $method = 'error500';
}
$this->template = $template;
$this->method = $method;
View
5 lib/Cake/Routing/Route/CakeRoute.php
@@ -154,7 +154,8 @@ protected function _writeRoute() {
if (preg_match('#\/\*\*$#', $route)) {
$parsed = preg_replace('#/\\\\\*\\\\\*$#', '(?:/(?P<_trailing_>.*))?', $parsed);
$this->_greedy = true;
- } elseif (preg_match('#\/\*$#', $route)) {
+ }
+ if (preg_match('#\/\*$#', $route)) {
$parsed = preg_replace('#/\\\\\*$#', '(?:/(?P<_args_>.*))?', $parsed);
$this->_greedy = true;
}
@@ -163,7 +164,7 @@ protected function _writeRoute() {
$this->_compiledRoute = '#^' . $parsed . '[/]*$#';
$this->keys = $names;
- //remove defaults that are also keys. They can cause match failures
+ // Remove defaults that are also keys. They can cause match failures
foreach ($this->keys as $key) {
unset($this->defaults[$key]);
}
View
26 lib/Cake/View/Helper.php
@@ -293,8 +293,9 @@ public function webroot($file) {
*/
public function assetUrl($path, $options = array()) {
if (is_array($path)) {
- $path = $this->url($path, !empty($options['fullBase']));
- } elseif (strpos($path, '://') === false) {
+ return $this->url($path, !empty($options['fullBase']));
+ }
+ if (strpos($path, '://') === false) {
if (!array_key_exists('plugin', $options) || $options['plugin'] !== false) {
list($plugin, $path) = $this->_View->pluginSplit($path, false);
}
@@ -322,7 +323,6 @@ public function assetUrl($path, $options = array()) {
$path = $base . $path;
}
}
-
return $path;
}
@@ -460,21 +460,21 @@ protected function _parseAttributes($options, $exclude = null, $insertBefore = '
* @deprecated This method will be moved to HtmlHelper in 3.0
*/
protected function _formatAttribute($key, $value, $escape = true) {
- $attribute = '';
if (is_array($value)) {
$value = implode(' ' , $value);
}
-
if (is_numeric($key)) {
- $attribute = sprintf($this->_minimizedAttributeFormat, $value, $value);
- } elseif (in_array($key, $this->_minimizedAttributes)) {
- if ($value === 1 || $value === true || $value === 'true' || $value === '1' || $value == $key) {
- $attribute = sprintf($this->_minimizedAttributeFormat, $key, $key);
- }
- } else {
- $attribute = sprintf($this->_attributeFormat, $key, ($escape ? h($value) : $value));
+ return sprintf($this->_minimizedAttributeFormat, $value, $value);
+ }
+ $truthy = array(1, '1', true, 'true', $key);
+ $isMinimized = in_array($key, $this->_minimizedAttributes);
+ if ($isMinimized && in_array($value, $truthy, true)) {
+ return sprintf($this->_minimizedAttributeFormat, $key, $key);
+ }
+ if ($isMinimized) {
+ return '';
}
- return $attribute;
+ return sprintf($this->_attributeFormat, $key, ($escape ? h($value) : $value));
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.