miquido/data-structure

View on GitHub
src/Value/Scalar/String/StringValue.php

Summary

Maintainability
A
0 mins
Test Coverage

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

    public function split(string $delimiter, int $limit = null): StringCollectionInterface
    {
        $limit = \is_int($limit) ? $limit : \PHP_INT_MAX;
        $strings = @\explode($delimiter, $this->value, $limit);
        if (false === $strings) {

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

Missing class import via use statement (line '56', column '23').
Open

            throw new \InvalidArgumentException(\sprintf('Could not explode a string "%s" by "%s"', $this->value, $delimiter));

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

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

Rename "$value" which has the same name as the field declared at line 16.
Open

        $value = $this->value;

Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

Noncompliant Code Example

class Foo {
  public $myField;

  public function doSomething() {
    $myField = 0;
    ...
  }
}

See

There are no issues that match your filters.

Category
Status