Codacy cleanup.

This commit is contained in:
Matthew Ross 2017-09-02 08:28:21 -04:00
parent b1aec2c146
commit 5d5af55cdd

View File

@ -268,7 +268,7 @@ class Tasks extends BaseController {
return true; return true;
} }
} }
} catch(Exception $ex) { } catch (Exception $ex) {
// Ignore // Ignore
} }
@ -318,7 +318,7 @@ class Tasks extends BaseController {
case ActionType::CLEAR_DUE_DATE(): case ActionType::CLEAR_DUE_DATE():
$task = R::load('task', $taskId); $task = R::load('task', $taskId);
if($task->due_date === '') { if ($task->due_date === '') {
break; break;
} }
@ -334,16 +334,17 @@ class Tasks extends BaseController {
$task = R::load('task', $taskId); $task = R::load('task', $taskId);
$diff = (float)$beforePoints - (float)$afterPoints; $diff = (float)$beforePoints - (float)$afterPoints;
// Steps should be between -255 and 255. Negative = darker, positive = lighter // Steps should be between -255 and 255.
// Negative = darker, positive = lighter
$steps = max(-255, min(255, $diff * 10)); $steps = max(-255, min(255, $diff * 10));
// Normalize into a six character long hex string // Normalize into a six character long hex string
$hex = $task->color; $hex = $task->color;
$hex = str_replace('#', '', $hex); $hex = str_replace('#', '', $hex);
if (strlen($hex) == 3) { if (strlen($hex) == 3) {
$hex = str_repeat(substr($hex,0,1), 2). $hex = str_repeat(substr($hex, 0, 1), 2).
str_repeat(substr($hex,1,1), 2). str_repeat(substr($hex, 1, 1), 2).
str_repeat(substr($hex,2,1), 2); str_repeat(substr($hex, 2, 1), 2);
} }
// Split into three parts: R, G and B // Split into three parts: R, G and B
@ -351,9 +352,12 @@ class Tasks extends BaseController {
$newColor = '#'; $newColor = '#';
foreach ($colorParts as $color) { foreach ($colorParts as $color) {
$color = hexdec($color); // Convert to decimal // Convert to decimal
$color = max(0,min(255,$color + $steps)); // Adjust color $color = hexdec($color);
$newColor .= str_pad(dechex($color), 2, '0', STR_PAD_LEFT); // Make two char hex code // Adjust color
$color = max(0, min(255, $color + $steps));
// Make two char hex code
$newColor .= str_pad(dechex($color), 2, '0', STR_PAD_LEFT);
} }
$task->color = $newColor; $task->color = $newColor;