webD97/chameleon

View on GitHub

Showing 19 of 89 total issues

Color has 158 functions (exceeds 20 allowed). Consider refactoring.
Open

abstract class Color implements IColor {
/**
* {@inheritdoc}
*/
public static abstract function fromRGBA(RGBAColor $rgba);
Severity: Major
Found in src/Colors/Color.php - About 3 days to fix

ColorTest has 149 functions (exceeds 20 allowed). Consider refactoring.
Open

final class ColorTest extends TestCase {
/**
* @covers \Chameleon\Colors\Color::transparent
*/
function testTransparent() {
Severity: Major
Found in test/Colors/ColorTest.php - About 2 days to fix

File Color.php has 489 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
namespace Chameleon\Colors;
 
use Exception;
 
 
Severity: Minor
Found in src/Colors/Color.php - About 7 hrs to fix

File ColorTest.php has 453 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
namespace Chameleon\Colors;
 
use PHPUnit\Framework\TestCase;
 
 
Severity: Minor
Found in test/Colors/ColorTest.php - About 6 hrs to fix

Image has 23 functions (exceeds 20 allowed). Consider refactoring.
Open

class Image {
private $imageResource;
/**
* @var IColor This color is used as initial background color when creating an image, or if a certain method
* needs a background color as parameter.
Severity: Minor
Found in src/Image.php - About 2 hrs to fix

Method apply has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

public function apply(Image $image) : bool {
if ($this -> getArg4() !== null) {
return imagefilter(
$image -> getImageResource(),
$this -> getFilterID(),
Severity: Minor
Found in src/Filters/BuiltinFilter.php - About 1 hr to fix

Method drawUnicolorBorder has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

private function drawUnicolorBorder(Image $image): self {
$backgroundColor = $this->borderPattern->getColorAt(0, 0);
$image->registerColor($backgroundColor);
 
// Top
Severity: Minor
Found in src/Primitives/Rectangle.php - About 1 hr to fix

Method fromRGBA has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

public static function fromRGBA(RGBAColor $rgba) : HSVColor {
// https://stackoverflow.com/a/6930407
$red = $rgba -> getRed() / 255;
$green = $rgba -> getGreen() / 255;
$blue = $rgba -> getBlue() / 255;
Severity: Minor
Found in src/Colors/HSVColor.php - About 1 hr to fix

Method fromRGBA has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

public static function fromRGBA(RGBAColor $rgba) {
// http://www.geekymonkey.com/Programming/CSharp/RGB2HSL_HSL2RGB.htm
$red = $rgba -> getRed() / 255;
$green = $rgba -> getGreen() / 255;
$blue = $rgba -> getBlue() / 255;
Severity: Minor
Found in src/Colors/HSLColor.php - About 1 hr to fix

Method outputFile has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

public function outputFile(int $type, array $options = [], $fileResource = null) : int {
$fileHandler = (is_resource($fileResource)) ? $fileResource : fopen("php://output", "w+");
 
ob_start();
switch ($type) {
Severity: Minor
Found in src/Image.php - About 1 hr to fix

Method makeRGB has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

private function makeRGB() : void {
$hueSector = intdiv($this -> hue, 60);
$f = ($this -> hue / 60) - $hueSector;
 
$p = $this -> value * (1 - $this -> saturation);
Severity: Minor
Found in src/Colors/HSVColor.php - About 1 hr to fix

Method __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

public function __construct(IColor $background, IColor $line, int $width = 2, int $height = 2, int $offsetX = 0, int $offsetY = 0) {
Severity: Minor
Found in src/Patterns/Grid.php - About 45 mins to fix

Method drawPattern has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

private function drawPattern(Image $image, IPattern $pattern, Mask $mask, int $startX, int $startY) {
Severity: Minor
Found in src/Primitives/Rectangle.php - About 35 mins to fix

Function createBorderMask has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

private function createBorderMask(): Mask {
$borderMask = new Mask($this->width + 2 * $this->borderThickness, $this->height + 2 * $this->borderThickness);
 
$width = $borderMask->getWidth();
$height = $borderMask->getHeight();
Severity: Minor
Found in src/Primitives/Rectangle.php - About 35 mins to fix

Function makeRGB has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

private function makeRGB() : void {
$hueSector = intdiv($this -> hue, 60);
$f = ($this -> hue / 60) - $hueSector;
 
$p = $this -> value * (1 - $this -> saturation);
Severity: Minor
Found in src/Colors/HSVColor.php - About 35 mins to fix

Function fromFile has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

public static function fromFile(string $path, IColor $backgroundColor = null) : self {
$backgroundColor = $backgroundColor ?? RGBColor::black();
 
if (file_exists($path)) {
$rawImage = null;
Severity: Minor
Found in src/Image.php - About 35 mins to fix

Avoid too many return statements within this method.
Open

return imagefilter(
$image -> getImageResource(),
$this -> getFilterID()
);
Severity: Major
Found in src/Filters/BuiltinFilter.php - About 30 mins to fix

Function __construct has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

public function __construct(int $red = 0, int $green = 0, int $blue = 0, int $alpha = 0) {
if ($red < 0 || $red > 255) {
throw new ValueOutOfBoundsException("red", $red, 0, 255);
}
if ($green < 0 || $green > 255) {
Severity: Minor
Found in src/Filters/ColorizeFilter.php - About 25 mins to fix

Function fromRGBA has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

public static function fromRGBA(RGBAColor $rgba) : HSVColor {
// https://stackoverflow.com/a/6930407
$red = $rgba -> getRed() / 255;
$green = $rgba -> getGreen() / 255;
$blue = $rgba -> getBlue() / 255;
Severity: Minor
Found in src/Colors/HSVColor.php - About 25 mins to fix
Severity
Category
Status
Source
Language