Showing 34 of 38 total issues
File index.php
has 792 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Source code of wsrv.nl (formerly images.weserv.nl), to be used on your own server(s).
*
* PHP version 7.4+
Method doThumbnail
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function doThumbnail(Image $image, string $fit, int $width, int $height): Image
{
// Default settings
$thumbnailOptions = [
'auto_rotate' => false,
Method outputImage
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function outputImage(string $uri, array $params): void
{
// Throttler can be null
if ($this->throttler !== null) {
// For PHPUnit check if REMOTE_ADDR is set
Consider simplifying this complex logical expression. Open
if (\count($coordinates) !== 4
|| (!is_numeric($coordinates[0]))
|| (!is_numeric($coordinates[1]))
|| (!is_numeric($coordinates[2]))
|| (!is_numeric($coordinates[3]))
Consider simplifying this complex logical expression. Open
if ($this->shape === 'circle' ||
$this->shape === 'ellipse' ||
$this->shape === 'hexagon' ||
$this->shape === 'pentagon' ||
$this->shape === 'pentagon-180' ||
Method getSVGShape
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getSVGShape(int $width, int $height, string $shape): array
{
$min = min($width, $height);
$outerRadius = $min / 2;
$midX = $width / 2;
Method run
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function run(Image $image): Image
{
// Skip this manipulator if:
// - There's no bg parameter.
// - The image doesn't have an alpha channel.
Method run
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function run(Image $image): Image
{
$width = $this->w;
$height = $this->h;
$imageWidth = $image->width;
Method initClient
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function initClient(array $guzzleOptions): void
{
$defaultConfig = [
'connect_timeout' => $this->options['connect_timeout'],
'decode_content' => true,
Method resolveRotationAndFlip
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function resolveRotationAndFlip(Image $image, array $params): array
{
$rotate = isset($params['or']) ? self::resolveAngleRotation($params['or']) : 0;
$flip = isset($params['flip']) || array_key_exists('flip', $params);
$flop = isset($params['flop']) || array_key_exists('flop', $params);
Method getCrop
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getCrop(): array
{
$cropMethods = [
'top-left' => [0, 0],
't' => [50, 0], // Deprecated use top instead
Method run
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function run(Image $image): Image
{
$shape = $this->getShape();
if ($shape !== null) {
Function run
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function run(Image $image): Image
{
$width = $this->w;
$height = $this->h;
$imageWidth = $image->width;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function log
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function log($level, $message, array $context = []): void
{
// Base64 encode buffers
/*if (($message === 'newFromBuffer' || $message === 'findLoadBuffer') &&
isset($context['arguments'][0])) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function getSharpen
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function getSharpen(): array
{
$sharpPieces = explode(',', $this->sharp);
$sharpenFlat = 1.0;
$sharpenJagged = 2.0;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method run
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function run(Image $image): Image
{
if ($this->blur === null) {
return $image;
}
Consider simplifying this complex logical expression. Open
if (($message === 'findLoad' || $message === 'findLoadBuffer' ||
$message === 'writeToFile' || $message === 'newFromFile' ||
$message === 'newFromBuffer' || $message === 'thumbnail') &&
isset($context['arguments'][0])
) {
Consider simplifying this complex logical expression. Open
if (isset($params['page']) && is_numeric($params['page']) &&
$params['page'] >= 0 && $params['page'] <= 100000 &&
($params['loader'] === 'VipsForeignLoadPdfFile' ||
$params['loader'] === 'VipsForeignLoadTiffFile' ||
$params['loader'] === 'VipsForeignLoadMagickFile')
Function getCrop
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function getCrop(): array
{
$cropMethods = [
'top-left' => [0, 0],
't' => [50, 0], // Deprecated use top instead
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function resolveRotationAndFlip
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function resolveRotationAndFlip(Image $image, array $params): array
{
$rotate = isset($params['or']) ? self::resolveAngleRotation($params['or']) : 0;
$flip = isset($params['flip']) || array_key_exists('flip', $params);
$flop = isset($params['flop']) || array_key_exists('flop', $params);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"