Color
has 158 functions (exceeds 20 allowed). Consider refactoring.
abstract class Color implements IColor {
* {@inheritdoc}
*/
public static abstract function fromRGBA(RGBAColor $rgba);
ColorTest
has 149 functions (exceeds 20 allowed). Consider refactoring.
final class ColorTest extends TestCase {
* @covers \Chameleon\Colors\Color::transparent
*/
function testTransparent() {
File Color.php
has 489 lines of code (exceeds 250 allowed). Consider refactoring.
<?php
namespace Chameleon\Colors;
use Exception;
File ColorTest.php
has 453 lines of code (exceeds 250 allowed). Consider refactoring.
<?php
namespace Chameleon\Colors;
use PHPUnit\Framework\TestCase;
Image
has 23 functions (exceeds 20 allowed). Consider refactoring.
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.
Method apply
has 38 lines of code (exceeds 25 allowed). Consider refactoring.
public function apply(Image $image) : bool {
if ($this -> getArg4() !== null) {
return imagefilter(
$image -> getImageResource(),
$this -> getFilterID(),
Method drawUnicolorBorder
has 35 lines of code (exceeds 25 allowed). Consider refactoring.
private function drawUnicolorBorder(Image $image): self {
$backgroundColor = $this->borderPattern->getColorAt(0, 0);
$image->registerColor($backgroundColor);
Method fromRGBA
has 30 lines of code (exceeds 25 allowed). Consider refactoring.
public static function fromRGBA(RGBAColor $rgba) : HSVColor {
$red = $rgba -> getRed() / 255;
$green = $rgba -> getGreen() / 255;
$blue = $rgba -> getBlue() / 255;
Method fromRGBA
has 29 lines of code (exceeds 25 allowed). Consider refactoring.
public static function fromRGBA(RGBAColor $rgba) {
$red = $rgba -> getRed() / 255;
$green = $rgba -> getGreen() / 255;
$blue = $rgba -> getBlue() / 255;
Method outputFile
has 28 lines of code (exceeds 25 allowed). Consider refactoring.
public function outputFile(int $type, array $options = [], $fileResource = null) : int {
$fileHandler = (is_resource($fileResource)) ? $fileResource : fopen("php://output", "w+");
ob_start();
switch ($type) {
Method makeRGB
has 26 lines of code (exceeds 25 allowed). Consider refactoring.
private function makeRGB() : void {
$hueSector = intdiv($this -> hue, 60);
$f = ($this -> hue / 60) - $hueSector;
$p = $this -> value * (1 - $this -> saturation);
Method __construct
has 6 arguments (exceeds 4 allowed). Consider refactoring.
public function __construct(IColor $background, IColor $line, int $width = 2, int $height = 2, int $offsetX = 0, int $offsetY = 0) {
Method drawPattern
has 5 arguments (exceeds 4 allowed). Consider refactoring.
private function drawPattern(Image $image, IPattern $pattern, Mask $mask, int $startX, int $startY) {
Function createBorderMask
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
private function createBorderMask(): Mask {
$borderMask = new Mask($this->width + 2 * $this->borderThickness, $this->height + 2 * $this->borderThickness);
$width = $borderMask->getWidth();
$height = $borderMask->getHeight();
Function makeRGB
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
private function makeRGB() : void {
$hueSector = intdiv($this -> hue, 60);
$f = ($this -> hue / 60) - $hueSector;
$p = $this -> value * (1 - $this -> saturation);
Function fromFile
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
public static function fromFile(string $path, IColor $backgroundColor = null) : self {
$backgroundColor = $backgroundColor ?? RGBColor::black();
if (file_exists($path)) {
$rawImage = null;
Avoid too many return
statements within this method.
return imagefilter(
$image -> getImageResource(),
$this -> getFilterID()
);
Function __construct
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
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) {
Function fromRGBA
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
public static function fromRGBA(RGBAColor $rgba) : HSVColor {
$red = $rgba -> getRed() / 255;
$green = $rgba -> getGreen() / 255;
$blue = $rgba -> getBlue() / 255;