Showing 44 of 100 total issues
File Storage.php
has 1026 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
namespace Autowp\Image;
File Sampler.php
has 558 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
namespace Autowp\Image;
Storage
has 53 functions (exceeds 20 allowed). Consider refactoring. Open
class Storage implements StorageInterface
{
private const EXTENSION_DEFAULT = 'jpg';
private const INSERT_MAX_ATTEMPTS = 15;
Method doFormatImage
has 116 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function doFormatImage(int $imageId, string $formatName): int
{
// find source image
/** @var ResultSet $resultSet */
$resultSet = $this->imageTable->select([
Function convertImagick
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
public function convertImagick(Imagick $imagick, ?array $crop, $format): Imagick
{
if (! $format instanceof Sampler\Format) {
if (! is_array($format)) {
throw new Sampler\Exception("Unexpected type of format");
- 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
Format
has 33 functions (exceeds 20 allowed). Consider refactoring. Open
class Format
{
public const
FIT_TYPE_INNER = 0, // вписать
FIT_TYPE_OUTER = 1, // описать
Method convertImagick
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function convertImagick(Imagick $imagick, ?array $crop, $format): Imagick
{
if (! $format instanceof Sampler\Format) {
if (! is_array($format)) {
throw new Sampler\Exception("Unexpected type of format");
Function cropImage
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
private function cropImage(Imagick $imagick, array $crop, Sampler\Format $format): Imagick
{
$cropSet = isset($crop['width'], $crop['height'], $crop['left'], $crop['top']);
if (! $cropSet) {
throw new Sampler\Exception('Crop parameters not properly set');
- 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 doFormatImage
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
private function doFormatImage(int $imageId, string $formatName): int
{
// find source image
/** @var ResultSet $resultSet */
$resultSet = $this->imageTable->select([
- 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 cropImage
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function cropImage(Imagick $imagick, array $crop, Sampler\Format $format): Imagick
{
$cropSet = isset($crop['width'], $crop['height'], $crop['left'], $crop['top']);
if (! $cropSet) {
throw new Sampler\Exception('Crop parameters not properly set');
Method addImageFromFile
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addImageFromFile(string $file, string $dirName, array $options = []): int
{
$imageInfo = getimagesize($file);
$width = (int) $imageInfo[0];
Method addImageFromImagick
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addImageFromImagick(Imagick $imagick, string $dirName, array $options = []): int
{
$width = $imagick->getImageWidth();
$height = $imagick->getImageHeight();
Method extendHorizontal
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function extendHorizontal(Imagick $imagick, Sampler\Format $format): void
{
$fRatio = (int) $format->getWidth() / (int) $format->getHeight();
$srcWidth = $imagick->getImageWidth();
Method extendVertical
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function extendVertical(Imagick $imagick, Sampler\Format $format): void
{
$fRatio = (int) $format->getWidth() / (int) $format->getHeight();
$srcWidth = $imagick->getImageWidth();
Method changeImageName
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function changeImageName(int $imageId, array $options = []): void
{
$imageRow = $this->getImageRow($imageId);
if (! $imageRow) {
throw new Storage\Exception("Image `$imageId` not found");
Method setImageCrop
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function setImageCrop(int $imageId, ?array $crop): void
{
if (! $imageId) {
throw new Storage\Exception("Invalid image id provided `$imageId`");
}
Method getConsoleConfig
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getConsoleConfig(): array
{
return [
'router' => [
'routes' => [
Method convertByOuterFit
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function convertByOuterFit(Imagick $imagick, Sampler\Format $format): Imagick
{
$srcWidth = $imagick->getImageWidth();
$srcHeight = $imagick->getImageHeight();
$srcRatio = $srcWidth / $srcHeight;
Method getImageResolution
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getImageResolution(int $imageId): ?array
{
$imageRow = $this->getImageRow($imageId);
if (! $imageRow) {
Method getFormatedImageRows
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getFormatedImageRows(array $imagesId, string $formatName): array
{
$destImageRows = [];
if (count($imagesId)) {
$select = $this->imageTable->getSql()->select()