SU-SWS/stanford_migrate

View on GitHub
src/Plugin/migrate/process/ImageDimensionSkip.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%

Remove error control operator '@' on line 123.
Open

  protected function getImageSize(string $url): bool|array {
    try {
      return @getimagesize($url);
    }
    catch (\Exception $e) {

ErrorControlOperator

Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

Example

function foo($filePath) {
    $file = @fopen($filPath); // hides exceptions
    $key = @$array[$notExistingKey]; // assigns null to $key
}

Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

Avoid assigning values to variables in if clauses and the like (line '102', column '9').
Open

  protected function isImageBigger($value) {
    if (!is_string($value)) {
      return FALSE;
    }

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

syntax error, unexpected '|', expecting ';' or '{'
Open

  protected function getImageSize(string $url): bool|array {

Variable $width is undefined.
Invalid

      $valid_width = empty($this->configuration['width']) ? TRUE : $this->configuration['width'] <= $width;

Variable $height is undefined.
Invalid

      $valid_height = empty($this->configuration['height']) ? TRUE : $this->configuration['height'] <= $height;

Expected 1 space after "|"; 0 found
Open

  protected function getImageSize(string $url): bool|array {

Variable $height is undefined.
Open

      [$width, $height] = $size;

Expected 1 space before "|"; 0 found
Open

  protected function getImageSize(string $url): bool|array {

Variable $width is undefined.
Open

      [$width, $height] = $size;

There are no issues that match your filters.

Category
Status