Method __construct
has 443 lines of code (exceeds 25 allowed). Consider refactoring.
public function __construct($aImg = null)
{
$this->img = $aImg;
File RGB.php
has 551 lines of code (exceeds 250 allowed). Consider refactoring.
<?php
* JPGraph v4.0.3
*/
Function Color
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
public function Color($aColor)
{
if (is_string($aColor)) {
$matches = [];
Method Color
has 45 lines of code (exceeds 25 allowed). Consider refactoring.
public function Color($aColor)
{
if (is_string($aColor)) {
$matches = [];
Function tryHexConversion
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
public static function tryHexConversion($aColor)
{
if (is_array($aColor)) {
if (safe_count($aColor) == 3) {
if (is_numeric($aColor[0]) && is_numeric($aColor[1]) && is_numeric($aColor[2])) {
Consider simplifying this complex logical expression.
if (($aColor[0] >= 0 && $aColor[0] <= 255) &&
($aColor[1] >= 0 && $aColor[1] <= 255) &&
($aColor[2] >= 0 && $aColor[2] <= 255)) {
return sprintf('#%02x%02x%02x', $aColor[0], $aColor[1], $aColor[2]);
}
Avoid too many return
statements within this method.
return [$sat, round($sat - $sat * ($aVal - 0.75) / $a), 0];
The method Color() has an NPath complexity of 1283. The configured NPath complexity threshold is 200.
public function Color($aColor)
{
if (is_string($aColor)) {
$matches = [];
The method __construct() has 448 lines of code. Current threshold is set to 100. Avoid really long methods.
public function __construct($aImg = null)
{
$this->img = $aImg;
The method Color() has a Cyclomatic Complexity of 16. The configured cyclomatic complexity threshold is 10.
public function Color($aColor)
{
if (is_string($aColor)) {
$matches = [];
The method tryHexConversion() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
public static function tryHexConversion($aColor)
{
if (is_array($aColor)) {
if (safe_count($aColor) == 3) {
if (is_numeric($aColor[0]) && is_numeric($aColor[1]) && is_numeric($aColor[2])) {
The method Color uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
} else {
JpGraphError::RaiseL(25079, $aColor, safe_count($aColor));
}
The method Color uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
} else {
if (!isset($this->rgb_table[$matches[5]])) {
JpGraphError::RaiseL(25078, $aColor);
}
$r = $this->rgb_table[$matches[5]][0];
Avoid using static access to class 'Amenadiel\JpGraph\Util\JpGraphError' in method 'Color'.
JpGraphError::RaiseL(25078, $aColor);
Avoid using static access to class 'Amenadiel\JpGraph\Util\JpGraphError' in method 'Color'.
JpGraphError::RaiseL(25077);
Avoid using static access to class 'Amenadiel\JpGraph\Util\JpGraphError' in method 'Color'.
JpGraphError::RaiseL(25079, $aColor, safe_count($aColor));
Avoid using static access to class 'Amenadiel\JpGraph\Util\JpGraphError' in method 'Color'.
JpGraphError::RaiseL(25078, $aColor);
Avoid using static access to class 'Amenadiel\JpGraph\Util\JpGraphError' in method 'Allocate'.
JpGraphError::RaiseL(25080);
Identical blocks of code found in 2 locations. Consider refactoring.
public function __construct($aImg = null)
{
$this->img = $aImg;
Similar blocks of code found in 2 locations. Consider refactoring.
if (empty($matches[5])) {
$r = strlen($matches[2]) == 1 ? $matches[2] . $matches[2] : $matches[2];
$g = strlen($matches[3]) == 1 ? $matches[3] . $matches[3] : $matches[3];
$b = strlen($matches[4]) == 1 ? $matches[4] . $matches[4] : $matches[4];
$r = hexdec($r);
Similar blocks of code found in 2 locations. Consider refactoring.
public static function GetSpectrum($aVal, $aDynamicRange = 1.0)
{
if ($aVal < 0 || $aVal > 1.0001) {
return [0, 0, 0];
}
Identical blocks of code found in 2 locations. Consider refactoring.
public static function tryHexConversion($aColor)
{
if (is_array($aColor)) {
if (safe_count($aColor) == 3) {
if (is_numeric($aColor[0]) && is_numeric($aColor[1]) && is_numeric($aColor[2])) {
Similar blocks of code found in 2 locations. Consider refactoring.
public function Allocate($aColor, $aAlpha = 0.0)
{
list($r, $g, $b, $a) = $this->color($aColor);
Identical blocks of code found in 2 locations. Consider refactoring.
if ($adj > 1) {
$m = ($adj - 1.0) * (255 - min(255, min($r, min($g, $b))));
return [min(255, $r + $m), min(255, $g + $m), min(255, $b + $m), $alpha];
}
Identical blocks of code found in 2 locations. Consider refactoring.
if ($adj < 1) {
$m = ($adj - 1.0) * max(255, max($r, max($g, $b)));
return [max(0, $r + $m), max(0, $g + $m), max(0, $b + $m), $alpha];
}
Avoid variables with short names like $c1. Configured minimum length is 3.
$c1 = $this->Color($aCol1);
Avoid variables with short names like $m. Configured minimum length is 3.
$m = ($adj - 1.0) * (255 - min(255, min($r, min($g, $b))));
Avoid variables with short names like $c2. Configured minimum length is 3.
$c2 = $this->Color($aCol2);
Avoid variables with short names like $g. Configured minimum length is 3.
$g = strlen($matches[3]) == 1 ? $matches[3] . $matches[3] : $matches[3];
Avoid variables with short names like $g. Configured minimum length is 3.
list($r, $g, $b, $a) = $this->color($aColor);
Avoid variables with short names like $a. Configured minimum length is 3.
$a = 0.25;
Avoid variables with short names like $r. Configured minimum length is 3.
$r = strlen($matches[2]) == 1 ? $matches[2] . $matches[2] : $matches[2];
Avoid variables with short names like $a. Configured minimum length is 3.
list($r, $g, $b, $a) = $this->color($aColor);
Avoid variables with short names like $r. Configured minimum length is 3.
list($r, $g, $b, $a) = $this->color($aColor);
Avoid variables with short names like $b. Configured minimum length is 3.
list($r, $g, $b, $a) = $this->color($aColor);
Avoid variables with short names like $b. Configured minimum length is 3.
$b = strlen($matches[4]) == 1 ? $matches[4] . $matches[4] : $matches[4];
Method name "RGB::GetSpectrum" is not in camel caps format
public static function GetSpectrum($aVal, $aDynamicRange = 1.0)
Method name "RGB::Color" is not in camel caps format
public function Color($aColor)
Method name "RGB::Allocate" is not in camel caps format
public function Allocate($aColor, $aAlpha = 0.0)
Method name "RGB::Equal" is not in camel caps format
public function Equal($aCol1, $aCol2)
Line exceeds 120 characters; contains 144 characters
JpGraphError::RaiseL(25079, $aColor, safe_count($aColor));
Line exceeds 120 characters; contains 122 characters
There are no issues that match your filters.