yiisoft/yii2

View on GitHub
framework/i18n/Formatter.php

Summary

Maintainability
F
1 wk
Test Coverage

Function asDecimalStringFallback has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
Open

    protected function asDecimalStringFallback($value, $decimals = 2)
    {
        if (empty($value)) {
            $value = 0;
        }
Severity: Minor
Found in framework/i18n/Formatter.php - About 7 hrs to fix

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 formatDateTimeValue has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    private function formatDateTimeValue($value, $format, $type)
    {
        $timeZone = $this->timeZone;
        // avoid time zone conversion for date-only and time-only values
        if ($type === 'date' || $type === 'time') {
Severity: Minor
Found in framework/i18n/Formatter.php - About 4 hrs to fix

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 asRelativeTime has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    public function asRelativeTime($value, $referenceTime = null)
    {
        if ($value === null) {
            return $this->nullDisplay;
        }
Severity: Minor
Found in framework/i18n/Formatter.php - About 3 hrs to fix

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

The class Formatter has an overall complexity of 281 which is very high. The configured complexity threshold is 50.
Open

class Formatter extends Component
{
    /**
     * @since 2.0.13
     */
Severity: Minor
Found in framework/i18n/Formatter.php by phpmd

The class Formatter has 41 non-getter- and setter-methods. Consider refactoring Formatter to keep number of methods under 25.
Open

class Formatter extends Component
{
    /**
     * @since 2.0.13
     */
Severity: Minor
Found in framework/i18n/Formatter.php by phpmd

TooManyMethods

Since: 0.1

A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

By default it ignores methods starting with 'get' or 'set'.

The default was changed from 10 to 25 in PHPMD 2.3.

Example

Source https://phpmd.org/rules/codesize.html#toomanymethods

The class Formatter has 30 public methods. Consider refactoring Formatter to keep number of public methods under 10.
Open

class Formatter extends Component
{
    /**
     * @since 2.0.13
     */
Severity: Minor
Found in framework/i18n/Formatter.php by phpmd

TooManyPublicMethods

Since: 0.1

A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

By default it ignores methods starting with 'get' or 'set'.

Example

Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

Function formatNumber has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    protected function formatNumber($value, $decimals, $maxPosition, $formatBase, $options, $textOptions)
    {
        $value = $this->normalizeNumericValue($value);

        $position = 0;
Severity: Minor
Found in framework/i18n/Formatter.php - About 2 hrs to fix

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 asCurrency has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function asCurrency($value, $currency = null, $options = [], $textOptions = [])
    {
        if ($value === null) {
            return $this->nullDisplay;
        }
Severity: Minor
Found in framework/i18n/Formatter.php - About 1 hr to fix

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 asDuration has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function asDuration($value, $implodeString = ', ', $negativeSign = '-')
    {
        if ($value === null) {
            return $this->nullDisplay;
        }
Severity: Minor
Found in framework/i18n/Formatter.php - About 1 hr to fix

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

The class Formatter has 25 fields. Consider redesigning Formatter to keep the number of fields under 15.
Open

class Formatter extends Component
{
    /**
     * @since 2.0.13
     */
Severity: Minor
Found in framework/i18n/Formatter.php by phpmd

TooManyFields

Since: 0.1

Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.

Example

class Person {
   protected $one;
   private $two;
   private $three;
   [... many more fields ...]
}

Source https://phpmd.org/rules/codesize.html#toomanyfields

The class Formatter has 51 public methods and attributes. Consider reducing the number of public items to less than 45.
Open

class Formatter extends Component
{
    /**
     * @since 2.0.13
     */
Severity: Minor
Found in framework/i18n/Formatter.php by phpmd

ExcessivePublicCount

Since: 0.1

A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.

Example

public class Foo {
    public $value;
    public $something;
    public $var;
    // [... more more public attributes ...]

    public function doWork() {}
    public function doMoreWork() {}
    public function doWorkAgain() {}
    // [... more more public methods ...]
}

Source https://phpmd.org/rules/codesize.html#excessivepubliccount

Function getUnitMessage has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    private function getUnitMessage($unitType, $unitFormat, $system, $position)
    {
        if (isset($this->_unitMessages[$unitType][$unitFormat][$system][$position])) {
            return $this->_unitMessages[$unitType][$unitFormat][$system][$position];
        }
Severity: Minor
Found in framework/i18n/Formatter.php - About 1 hr to fix

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 init has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function init()
    {
        if ($this->timeZone === null) {
            $this->timeZone = Yii::$app->timeZone;
        }
Severity: Minor
Found in framework/i18n/Formatter.php - About 1 hr to fix

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 normalizeNumericStringValue has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    protected function normalizeNumericStringValue($value)
    {
        $powerPosition = strrpos($value, 'E');
        if ($powerPosition !== false) {
            $valuePart = substr($value, 0, $powerPosition);
Severity: Minor
Found in framework/i18n/Formatter.php - About 1 hr to fix

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 createNumberFormatter has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    protected function createNumberFormatter($style, $decimals = null, $options = [], $textOptions = [])
    {
        $formatter = new NumberFormatter($this->locale, $style);

        // set text attributes
Severity: Minor
Found in framework/i18n/Formatter.php - About 55 mins to fix

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 normalizeDatetimeValue has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    protected function normalizeDatetimeValue($value, $checkDateTimeInfo = false)
    {
        // checking for DateTime and DateTimeInterface is not redundant, DateTimeInterface is only in PHP>5.5
        if ($value === null || $value instanceof DateTime || $value instanceof DateTimeInterface) {
            // skip any processing
Severity: Minor
Found in framework/i18n/Formatter.php - About 55 mins to fix

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

Avoid deeply nested control flow statements.
Open

                        if ($oneUp === 10) {
                            $oneUp = 0;
                            $carry = 1;
                        }
Severity: Major
Found in framework/i18n/Formatter.php - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if ($carry === 0) {
                                break;
                            }
    Severity: Major
    Found in framework/i18n/Formatter.php - About 45 mins to fix

      Method formatUnit has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          private function formatUnit($unitType, $unitFormat, $value, $decimals, $options, $textOptions)
      Severity: Minor
      Found in framework/i18n/Formatter.php - About 45 mins to fix

        Method formatNumber has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            protected function formatNumber($value, $decimals, $maxPosition, $formatBase, $options, $textOptions)
        Severity: Minor
        Found in framework/i18n/Formatter.php - About 45 mins to fix

          Consider simplifying this complex logical expression.
          Open

                      if ($checkDateTimeInfo) {
                          $timestamp = new DateTime($value, new DateTimeZone($this->defaultTimeZone));
                          $info = date_parse($value);
                          return [
                              $timestamp,
          Severity: Major
          Found in framework/i18n/Formatter.php - About 40 mins to fix

            Method setFormatterTextAttribute has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                private function setFormatterTextAttribute($formatter, $attribute, $value, $source, $alternative)
            Severity: Minor
            Found in framework/i18n/Formatter.php - About 35 mins to fix

              Method setFormatterIntAttribute has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  private function setFormatterIntAttribute($formatter, $attribute, $value, $source, $alternative)
              Severity: Minor
              Found in framework/i18n/Formatter.php - About 35 mins to fix

                Function asPercentStringFallback has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function asPercentStringFallback($value, $decimals = null)
                    {
                        if (empty($value)) {
                            $value = 0;
                        }
                Severity: Minor
                Found in framework/i18n/Formatter.php - About 35 mins to fix

                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

                Avoid too many return statements within this method.
                Open

                            return Yii::t('yii', 'just now', [], $this->language);
                Severity: Major
                Found in framework/i18n/Formatter.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return new DateTime($value, new DateTimeZone($this->defaultTimeZone));
                  Severity: Major
                  Found in framework/i18n/Formatter.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return Yii::t('yii', '{delta, plural, =1{a month} other{# months}} ago', ['delta' => $interval->m], $this->language);
                    Severity: Major
                    Found in framework/i18n/Formatter.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return Yii::t('yii', '{delta, plural, =1{an hour} other{# hours}} ago', ['delta' => $interval->h], $this->language);
                      Severity: Major
                      Found in framework/i18n/Formatter.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                        return Yii::t('yii', 'in {delta, plural, =1{an hour} other{# hours}}', ['delta' => $interval->h], $this->language);
                        Severity: Major
                        Found in framework/i18n/Formatter.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                          return Yii::t('yii', 'just now', [], $this->language);
                          Severity: Major
                          Found in framework/i18n/Formatter.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                                return Yii::t('yii', '{nFormatted} GiB', $params, $this->language);
                            Severity: Major
                            Found in framework/i18n/Formatter.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                          return Yii::t('yii', 'in {delta, plural, =1{a second} other{# seconds}}', ['delta' => $interval->s], $this->language);
                              Severity: Major
                              Found in framework/i18n/Formatter.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                            return Yii::t('yii', '{delta, plural, =1{a year} other{# years}} ago', ['delta' => $interval->y], $this->language);
                                Severity: Major
                                Found in framework/i18n/Formatter.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                      return Yii::t('yii', '{nFormatted} PiB', $params, $this->language);
                                  Severity: Major
                                  Found in framework/i18n/Formatter.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                    return Yii::t('yii', 'in {delta, plural, =1{a minute} other{# minutes}}', ['delta' => $interval->i], $this->language);
                                    Severity: Major
                                    Found in framework/i18n/Formatter.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                  return Yii::t('yii', '{delta, plural, =1{a day} other{# days}} ago', ['delta' => $interval->d], $this->language);
                                      Severity: Major
                                      Found in framework/i18n/Formatter.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                    return Yii::t('yii', '{delta, plural, =1{a minute} other{# minutes}} ago', ['delta' => $interval->i], $this->language);
                                        Severity: Major
                                        Found in framework/i18n/Formatter.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                              return Yii::t('yii', '{nFormatted} TiB', $params, $this->language);
                                          Severity: Major
                                          Found in framework/i18n/Formatter.php - About 30 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

                                                            return [
                                                                $timestamp,
                                                                !($info['hour'] === false && $info['minute'] === false && $info['second'] === false),
                                                                !($info['year'] === false && $info['month'] === false && $info['day'] === false && empty($info['zone'])),
                                                            ];
                                            Severity: Major
                                            Found in framework/i18n/Formatter.php - About 30 mins to fix

                                              Avoid too many return statements within this method.
                                              Open

                                                      return Yii::t('yii', '{delta, plural, =1{a second} other{# seconds}} ago', ['delta' => $interval->s], $this->language);
                                              Severity: Major
                                              Found in framework/i18n/Formatter.php - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                                    return Yii::t('yii', '{nFormatted} {n, plural, =1{gibibyte} other{gibibytes}}', $params, $this->language);
                                                Severity: Major
                                                Found in framework/i18n/Formatter.php - About 30 mins to fix

                                                  Avoid too many return statements within this method.
                                                  Open

                                                                      return Yii::t('yii', '{nFormatted} {n, plural, =1{kilobyte} other{kilobytes}}', $params, $this->language);
                                                  Severity: Major
                                                  Found in framework/i18n/Formatter.php - About 30 mins to fix

                                                    Avoid too many return statements within this method.
                                                    Open

                                                                        return Yii::t('yii', '{nFormatted} kB', $params, $this->language);
                                                    Severity: Major
                                                    Found in framework/i18n/Formatter.php - About 30 mins to fix

                                                      Avoid too many return statements within this method.
                                                      Open

                                                                          return Yii::t('yii', '{nFormatted} {n, plural, =1{megabyte} other{megabytes}}', $params, $this->language);
                                                      Severity: Major
                                                      Found in framework/i18n/Formatter.php - About 30 mins to fix

                                                        Avoid too many return statements within this method.
                                                        Open

                                                                            return Yii::t('yii', '{nFormatted} {n, plural, =1{petabyte} other{petabytes}}', $params, $this->language);
                                                        Severity: Major
                                                        Found in framework/i18n/Formatter.php - About 30 mins to fix

                                                          Avoid too many return statements within this method.
                                                          Open

                                                                              return Yii::t('yii', '{nFormatted} {n, plural, =1{byte} other{bytes}}', $params, $this->language);
                                                          Severity: Major
                                                          Found in framework/i18n/Formatter.php - About 30 mins to fix

                                                            Avoid too many return statements within this method.
                                                            Open

                                                                                return Yii::t('yii', '{nFormatted} B', $params, $this->language);
                                                            Severity: Major
                                                            Found in framework/i18n/Formatter.php - About 30 mins to fix

                                                              Avoid too many return statements within this method.
                                                              Open

                                                                                  return Yii::t('yii', '{nFormatted} MB', $params, $this->language);
                                                              Severity: Major
                                                              Found in framework/i18n/Formatter.php - About 30 mins to fix

                                                                Avoid too many return statements within this method.
                                                                Open

                                                                                    return Yii::t('yii', '{nFormatted} GB', $params, $this->language);
                                                                Severity: Major
                                                                Found in framework/i18n/Formatter.php - About 30 mins to fix

                                                                  Avoid too many return statements within this method.
                                                                  Open

                                                                                      return Yii::t('yii', '{nFormatted} TB', $params, $this->language);
                                                                  Severity: Major
                                                                  Found in framework/i18n/Formatter.php - About 30 mins to fix

                                                                    Avoid too many return statements within this method.
                                                                    Open

                                                                                        return Yii::t('yii', '{nFormatted} {n, plural, =1{pebibyte} other{pebibytes}}', $params, $this->language);
                                                                    Severity: Major
                                                                    Found in framework/i18n/Formatter.php - About 30 mins to fix

                                                                      Avoid too many return statements within this method.
                                                                      Open

                                                                                          return Yii::t('yii', '{nFormatted} {n, plural, =1{gigabyte} other{gigabytes}}', $params, $this->language);
                                                                      Severity: Major
                                                                      Found in framework/i18n/Formatter.php - About 30 mins to fix

                                                                        Avoid too many return statements within this method.
                                                                        Open

                                                                                            return Yii::t('yii', '{nFormatted} {n, plural, =1{terabyte} other{terabytes}}', $params, $this->language);
                                                                        Severity: Major
                                                                        Found in framework/i18n/Formatter.php - About 30 mins to fix

                                                                          Avoid too many return statements within this method.
                                                                          Open

                                                                                              return Yii::t('yii', '{nFormatted} PB', $params, $this->language);
                                                                          Severity: Major
                                                                          Found in framework/i18n/Formatter.php - About 30 mins to fix

                                                                            Avoid too many return statements within this method.
                                                                            Open

                                                                                                return Yii::t('yii', '{nFormatted} {n, plural, =1{tebibyte} other{tebibytes}}', $params, $this->language);
                                                                            Severity: Major
                                                                            Found in framework/i18n/Formatter.php - About 30 mins to fix

                                                                              Function asDecimal has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                              Open

                                                                                  public function asDecimal($value, $decimals = null, $options = [], $textOptions = [])
                                                                                  {
                                                                                      if ($value === null) {
                                                                                          return $this->nullDisplay;
                                                                                      }
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php - About 25 mins to fix

                                                                              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 format has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                              Open

                                                                                  public function format($value, $format)
                                                                                  {
                                                                                      if ($format instanceof Closure) {
                                                                                          return $format($value, $this);
                                                                                      }
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php - About 25 mins to fix

                                                                              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 asPercent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                              Open

                                                                                  public function asPercent($value, $decimals = null, $options = [], $textOptions = [])
                                                                                  {
                                                                                      if ($value === null) {
                                                                                          return $this->nullDisplay;
                                                                                      }
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php - About 25 mins to fix

                                                                              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

                                                                              The method formatNumber() has an NPath complexity of 378. The configured NPath complexity threshold is 200.
                                                                              Open

                                                                                  protected function formatNumber($value, $decimals, $maxPosition, $formatBase, $options, $textOptions)
                                                                                  {
                                                                                      $value = $this->normalizeNumericValue($value);
                                                                              
                                                                                      $position = 0;
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              NPathComplexity

                                                                              Since: 0.1

                                                                              The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                              Example

                                                                              class Foo {
                                                                                  function bar() {
                                                                                      // lots of complicated code
                                                                                  }
                                                                              }

                                                                              Source https://phpmd.org/rules/codesize.html#npathcomplexity

                                                                              The method formatDateTimeValue() has an NPath complexity of 1680. The configured NPath complexity threshold is 200.
                                                                              Open

                                                                                  private function formatDateTimeValue($value, $format, $type)
                                                                                  {
                                                                                      $timeZone = $this->timeZone;
                                                                                      // avoid time zone conversion for date-only and time-only values
                                                                                      if ($type === 'date' || $type === 'time') {
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              NPathComplexity

                                                                              Since: 0.1

                                                                              The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                              Example

                                                                              class Foo {
                                                                                  function bar() {
                                                                                      // lots of complicated code
                                                                                  }
                                                                              }

                                                                              Source https://phpmd.org/rules/codesize.html#npathcomplexity

                                                                              The method createNumberFormatter() has an NPath complexity of 512. The configured NPath complexity threshold is 200.
                                                                              Open

                                                                                  protected function createNumberFormatter($style, $decimals = null, $options = [], $textOptions = [])
                                                                                  {
                                                                                      $formatter = new NumberFormatter($this->locale, $style);
                                                                              
                                                                                      // set text attributes
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              NPathComplexity

                                                                              Since: 0.1

                                                                              The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                              Example

                                                                              class Foo {
                                                                                  function bar() {
                                                                                      // lots of complicated code
                                                                                  }
                                                                              }

                                                                              Source https://phpmd.org/rules/codesize.html#npathcomplexity

                                                                              The method normalizeDatetimeValue() has an NPath complexity of 1630. The configured NPath complexity threshold is 200.
                                                                              Open

                                                                                  protected function normalizeDatetimeValue($value, $checkDateTimeInfo = false)
                                                                                  {
                                                                                      // checking for DateTime and DateTimeInterface is not redundant, DateTimeInterface is only in PHP>5.5
                                                                                      if ($value === null || $value instanceof DateTime || $value instanceof DateTimeInterface) {
                                                                                          // skip any processing
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              NPathComplexity

                                                                              Since: 0.1

                                                                              The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                              Example

                                                                              class Foo {
                                                                                  function bar() {
                                                                                      // lots of complicated code
                                                                                  }
                                                                              }

                                                                              Source https://phpmd.org/rules/codesize.html#npathcomplexity

                                                                              The method asCurrency() has an NPath complexity of 300. The configured NPath complexity threshold is 200.
                                                                              Open

                                                                                  public function asCurrency($value, $currency = null, $options = [], $textOptions = [])
                                                                                  {
                                                                                      if ($value === null) {
                                                                                          return $this->nullDisplay;
                                                                                      }
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              NPathComplexity

                                                                              Since: 0.1

                                                                              The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                              Example

                                                                              class Foo {
                                                                                  function bar() {
                                                                                      // lots of complicated code
                                                                                  }
                                                                              }

                                                                              Source https://phpmd.org/rules/codesize.html#npathcomplexity

                                                                              The method asDuration() has an NPath complexity of 6144. The configured NPath complexity threshold is 200.
                                                                              Open

                                                                                  public function asDuration($value, $implodeString = ', ', $negativeSign = '-')
                                                                                  {
                                                                                      if ($value === null) {
                                                                                          return $this->nullDisplay;
                                                                                      }
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              NPathComplexity

                                                                              Since: 0.1

                                                                              The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                              Example

                                                                              class Foo {
                                                                                  function bar() {
                                                                                      // lots of complicated code
                                                                                  }
                                                                              }

                                                                              Source https://phpmd.org/rules/codesize.html#npathcomplexity

                                                                              The method asRelativeTime() has an NPath complexity of 24960. The configured NPath complexity threshold is 200.
                                                                              Open

                                                                                  public function asRelativeTime($value, $referenceTime = null)
                                                                                  {
                                                                                      if ($value === null) {
                                                                                          return $this->nullDisplay;
                                                                                      }
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              NPathComplexity

                                                                              Since: 0.1

                                                                              The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                              Example

                                                                              class Foo {
                                                                                  function bar() {
                                                                                      // lots of complicated code
                                                                                  }
                                                                              }

                                                                              Source https://phpmd.org/rules/codesize.html#npathcomplexity

                                                                              The method asDecimalStringFallback() has 103 lines of code. Current threshold is set to 100. Avoid really long methods.
                                                                              Open

                                                                                  protected function asDecimalStringFallback($value, $decimals = 2)
                                                                                  {
                                                                                      if (empty($value)) {
                                                                                          $value = 0;
                                                                                      }
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              The class Formatter has 2137 lines of code. Current threshold is 1000. Avoid really long classes.
                                                                              Open

                                                                              class Formatter extends Component
                                                                              {
                                                                                  /**
                                                                                   * @since 2.0.13
                                                                                   */
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              The method asDecimalStringFallback() has an NPath complexity of 10640. The configured NPath complexity threshold is 200.
                                                                              Open

                                                                                  protected function asDecimalStringFallback($value, $decimals = 2)
                                                                                  {
                                                                                      if (empty($value)) {
                                                                                          $value = 0;
                                                                                      }
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              NPathComplexity

                                                                              Since: 0.1

                                                                              The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                              Example

                                                                              class Foo {
                                                                                  function bar() {
                                                                                      // lots of complicated code
                                                                                  }
                                                                              }

                                                                              Source https://phpmd.org/rules/codesize.html#npathcomplexity

                                                                              The method formatNumber() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10.
                                                                              Open

                                                                                  protected function formatNumber($value, $decimals, $maxPosition, $formatBase, $options, $textOptions)
                                                                                  {
                                                                                      $value = $this->normalizeNumericValue($value);
                                                                              
                                                                                      $position = 0;
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              CyclomaticComplexity

                                                                              Since: 0.1

                                                                              Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                              Example

                                                                              // Cyclomatic Complexity = 11
                                                                              class Foo {
                                                                              1   public function example() {
                                                                              2       if ($a == $b) {
                                                                              3           if ($a1 == $b1) {
                                                                                              fiddle();
                                                                              4           } elseif ($a2 == $b2) {
                                                                                              fiddle();
                                                                                          } else {
                                                                                              fiddle();
                                                                                          }
                                                                              5       } elseif ($c == $d) {
                                                                              6           while ($c == $d) {
                                                                                              fiddle();
                                                                                          }
                                                                              7        } elseif ($e == $f) {
                                                                              8           for ($n = 0; $n < $h; $n++) {
                                                                                              fiddle();
                                                                                          }
                                                                                      } else {
                                                                                          switch ($z) {
                                                                              9               case 1:
                                                                                                  fiddle();
                                                                                                  break;
                                                                              10              case 2:
                                                                                                  fiddle();
                                                                                                  break;
                                                                              11              case 3:
                                                                                                  fiddle();
                                                                                                  break;
                                                                                              default:
                                                                                                  fiddle();
                                                                                                  break;
                                                                                          }
                                                                                      }
                                                                                  }
                                                                              }

                                                                              Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                              The method asDuration() has a Cyclomatic Complexity of 15. The configured cyclomatic complexity threshold is 10.
                                                                              Open

                                                                                  public function asDuration($value, $implodeString = ', ', $negativeSign = '-')
                                                                                  {
                                                                                      if ($value === null) {
                                                                                          return $this->nullDisplay;
                                                                                      }
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              CyclomaticComplexity

                                                                              Since: 0.1

                                                                              Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                              Example

                                                                              // Cyclomatic Complexity = 11
                                                                              class Foo {
                                                                              1   public function example() {
                                                                              2       if ($a == $b) {
                                                                              3           if ($a1 == $b1) {
                                                                                              fiddle();
                                                                              4           } elseif ($a2 == $b2) {
                                                                                              fiddle();
                                                                                          } else {
                                                                                              fiddle();
                                                                                          }
                                                                              5       } elseif ($c == $d) {
                                                                              6           while ($c == $d) {
                                                                                              fiddle();
                                                                                          }
                                                                              7        } elseif ($e == $f) {
                                                                              8           for ($n = 0; $n < $h; $n++) {
                                                                                              fiddle();
                                                                                          }
                                                                                      } else {
                                                                                          switch ($z) {
                                                                              9               case 1:
                                                                                                  fiddle();
                                                                                                  break;
                                                                              10              case 2:
                                                                                                  fiddle();
                                                                                                  break;
                                                                              11              case 3:
                                                                                                  fiddle();
                                                                                                  break;
                                                                                              default:
                                                                                                  fiddle();
                                                                                                  break;
                                                                                          }
                                                                                      }
                                                                                  }
                                                                              }

                                                                              Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                              The method asCurrency() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
                                                                              Open

                                                                                  public function asCurrency($value, $currency = null, $options = [], $textOptions = [])
                                                                                  {
                                                                                      if ($value === null) {
                                                                                          return $this->nullDisplay;
                                                                                      }
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              CyclomaticComplexity

                                                                              Since: 0.1

                                                                              Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                              Example

                                                                              // Cyclomatic Complexity = 11
                                                                              class Foo {
                                                                              1   public function example() {
                                                                              2       if ($a == $b) {
                                                                              3           if ($a1 == $b1) {
                                                                                              fiddle();
                                                                              4           } elseif ($a2 == $b2) {
                                                                                              fiddle();
                                                                                          } else {
                                                                                              fiddle();
                                                                                          }
                                                                              5       } elseif ($c == $d) {
                                                                              6           while ($c == $d) {
                                                                                              fiddle();
                                                                                          }
                                                                              7        } elseif ($e == $f) {
                                                                              8           for ($n = 0; $n < $h; $n++) {
                                                                                              fiddle();
                                                                                          }
                                                                                      } else {
                                                                                          switch ($z) {
                                                                              9               case 1:
                                                                                                  fiddle();
                                                                                                  break;
                                                                              10              case 2:
                                                                                                  fiddle();
                                                                                                  break;
                                                                              11              case 3:
                                                                                                  fiddle();
                                                                                                  break;
                                                                                              default:
                                                                                                  fiddle();
                                                                                                  break;
                                                                                          }
                                                                                      }
                                                                                  }
                                                                              }

                                                                              Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                              The method asShortSize() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10.
                                                                              Open

                                                                                  public function asShortSize($value, $decimals = null, $options = [], $textOptions = [])
                                                                                  {
                                                                                      if ($value === null) {
                                                                                          return $this->nullDisplay;
                                                                                      }
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              CyclomaticComplexity

                                                                              Since: 0.1

                                                                              Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                              Example

                                                                              // Cyclomatic Complexity = 11
                                                                              class Foo {
                                                                              1   public function example() {
                                                                              2       if ($a == $b) {
                                                                              3           if ($a1 == $b1) {
                                                                                              fiddle();
                                                                              4           } elseif ($a2 == $b2) {
                                                                                              fiddle();
                                                                                          } else {
                                                                                              fiddle();
                                                                                          }
                                                                              5       } elseif ($c == $d) {
                                                                              6           while ($c == $d) {
                                                                                              fiddle();
                                                                                          }
                                                                              7        } elseif ($e == $f) {
                                                                              8           for ($n = 0; $n < $h; $n++) {
                                                                                              fiddle();
                                                                                          }
                                                                                      } else {
                                                                                          switch ($z) {
                                                                              9               case 1:
                                                                                                  fiddle();
                                                                                                  break;
                                                                              10              case 2:
                                                                                                  fiddle();
                                                                                                  break;
                                                                              11              case 3:
                                                                                                  fiddle();
                                                                                                  break;
                                                                                              default:
                                                                                                  fiddle();
                                                                                                  break;
                                                                                          }
                                                                                      }
                                                                                  }
                                                                              }

                                                                              Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                              The method formatDateTimeValue() has a Cyclomatic Complexity of 20. The configured cyclomatic complexity threshold is 10.
                                                                              Open

                                                                                  private function formatDateTimeValue($value, $format, $type)
                                                                                  {
                                                                                      $timeZone = $this->timeZone;
                                                                                      // avoid time zone conversion for date-only and time-only values
                                                                                      if ($type === 'date' || $type === 'time') {
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              CyclomaticComplexity

                                                                              Since: 0.1

                                                                              Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                              Example

                                                                              // Cyclomatic Complexity = 11
                                                                              class Foo {
                                                                              1   public function example() {
                                                                              2       if ($a == $b) {
                                                                              3           if ($a1 == $b1) {
                                                                                              fiddle();
                                                                              4           } elseif ($a2 == $b2) {
                                                                                              fiddle();
                                                                                          } else {
                                                                                              fiddle();
                                                                                          }
                                                                              5       } elseif ($c == $d) {
                                                                              6           while ($c == $d) {
                                                                                              fiddle();
                                                                                          }
                                                                              7        } elseif ($e == $f) {
                                                                              8           for ($n = 0; $n < $h; $n++) {
                                                                                              fiddle();
                                                                                          }
                                                                                      } else {
                                                                                          switch ($z) {
                                                                              9               case 1:
                                                                                                  fiddle();
                                                                                                  break;
                                                                              10              case 2:
                                                                                                  fiddle();
                                                                                                  break;
                                                                              11              case 3:
                                                                                                  fiddle();
                                                                                                  break;
                                                                                              default:
                                                                                                  fiddle();
                                                                                                  break;
                                                                                          }
                                                                                      }
                                                                                  }
                                                                              }

                                                                              Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                              The method normalizeDatetimeValue() has a Cyclomatic Complexity of 19. The configured cyclomatic complexity threshold is 10.
                                                                              Open

                                                                                  protected function normalizeDatetimeValue($value, $checkDateTimeInfo = false)
                                                                                  {
                                                                                      // checking for DateTime and DateTimeInterface is not redundant, DateTimeInterface is only in PHP>5.5
                                                                                      if ($value === null || $value instanceof DateTime || $value instanceof DateTimeInterface) {
                                                                                          // skip any processing
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              CyclomaticComplexity

                                                                              Since: 0.1

                                                                              Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                              Example

                                                                              // Cyclomatic Complexity = 11
                                                                              class Foo {
                                                                              1   public function example() {
                                                                              2       if ($a == $b) {
                                                                              3           if ($a1 == $b1) {
                                                                                              fiddle();
                                                                              4           } elseif ($a2 == $b2) {
                                                                                              fiddle();
                                                                                          } else {
                                                                                              fiddle();
                                                                                          }
                                                                              5       } elseif ($c == $d) {
                                                                              6           while ($c == $d) {
                                                                                              fiddle();
                                                                                          }
                                                                              7        } elseif ($e == $f) {
                                                                              8           for ($n = 0; $n < $h; $n++) {
                                                                                              fiddle();
                                                                                          }
                                                                                      } else {
                                                                                          switch ($z) {
                                                                              9               case 1:
                                                                                                  fiddle();
                                                                                                  break;
                                                                              10              case 2:
                                                                                                  fiddle();
                                                                                                  break;
                                                                              11              case 3:
                                                                                                  fiddle();
                                                                                                  break;
                                                                                              default:
                                                                                                  fiddle();
                                                                                                  break;
                                                                                          }
                                                                                      }
                                                                                  }
                                                                              }

                                                                              Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                              The method asSize() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10.
                                                                              Open

                                                                                  public function asSize($value, $decimals = null, $options = [], $textOptions = [])
                                                                                  {
                                                                                      if ($value === null) {
                                                                                          return $this->nullDisplay;
                                                                                      }
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              CyclomaticComplexity

                                                                              Since: 0.1

                                                                              Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                              Example

                                                                              // Cyclomatic Complexity = 11
                                                                              class Foo {
                                                                              1   public function example() {
                                                                              2       if ($a == $b) {
                                                                              3           if ($a1 == $b1) {
                                                                                              fiddle();
                                                                              4           } elseif ($a2 == $b2) {
                                                                                              fiddle();
                                                                                          } else {
                                                                                              fiddle();
                                                                                          }
                                                                              5       } elseif ($c == $d) {
                                                                              6           while ($c == $d) {
                                                                                              fiddle();
                                                                                          }
                                                                              7        } elseif ($e == $f) {
                                                                              8           for ($n = 0; $n < $h; $n++) {
                                                                                              fiddle();
                                                                                          }
                                                                                      } else {
                                                                                          switch ($z) {
                                                                              9               case 1:
                                                                                                  fiddle();
                                                                                                  break;
                                                                              10              case 2:
                                                                                                  fiddle();
                                                                                                  break;
                                                                              11              case 3:
                                                                                                  fiddle();
                                                                                                  break;
                                                                                              default:
                                                                                                  fiddle();
                                                                                                  break;
                                                                                          }
                                                                                      }
                                                                                  }
                                                                              }

                                                                              Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                              The method createNumberFormatter() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
                                                                              Open

                                                                                  protected function createNumberFormatter($style, $decimals = null, $options = [], $textOptions = [])
                                                                                  {
                                                                                      $formatter = new NumberFormatter($this->locale, $style);
                                                                              
                                                                                      // set text attributes
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              CyclomaticComplexity

                                                                              Since: 0.1

                                                                              Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                              Example

                                                                              // Cyclomatic Complexity = 11
                                                                              class Foo {
                                                                              1   public function example() {
                                                                              2       if ($a == $b) {
                                                                              3           if ($a1 == $b1) {
                                                                                              fiddle();
                                                                              4           } elseif ($a2 == $b2) {
                                                                                              fiddle();
                                                                                          } else {
                                                                                              fiddle();
                                                                                          }
                                                                              5       } elseif ($c == $d) {
                                                                              6           while ($c == $d) {
                                                                                              fiddle();
                                                                                          }
                                                                              7        } elseif ($e == $f) {
                                                                              8           for ($n = 0; $n < $h; $n++) {
                                                                                              fiddle();
                                                                                          }
                                                                                      } else {
                                                                                          switch ($z) {
                                                                              9               case 1:
                                                                                                  fiddle();
                                                                                                  break;
                                                                              10              case 2:
                                                                                                  fiddle();
                                                                                                  break;
                                                                              11              case 3:
                                                                                                  fiddle();
                                                                                                  break;
                                                                                              default:
                                                                                                  fiddle();
                                                                                                  break;
                                                                                          }
                                                                                      }
                                                                                  }
                                                                              }

                                                                              Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                              The method asDecimalStringFallback() has a Cyclomatic Complexity of 24. The configured cyclomatic complexity threshold is 10.
                                                                              Open

                                                                                  protected function asDecimalStringFallback($value, $decimals = 2)
                                                                                  {
                                                                                      if (empty($value)) {
                                                                                          $value = 0;
                                                                                      }
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              CyclomaticComplexity

                                                                              Since: 0.1

                                                                              Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                              Example

                                                                              // Cyclomatic Complexity = 11
                                                                              class Foo {
                                                                              1   public function example() {
                                                                              2       if ($a == $b) {
                                                                              3           if ($a1 == $b1) {
                                                                                              fiddle();
                                                                              4           } elseif ($a2 == $b2) {
                                                                                              fiddle();
                                                                                          } else {
                                                                                              fiddle();
                                                                                          }
                                                                              5       } elseif ($c == $d) {
                                                                              6           while ($c == $d) {
                                                                                              fiddle();
                                                                                          }
                                                                              7        } elseif ($e == $f) {
                                                                              8           for ($n = 0; $n < $h; $n++) {
                                                                                              fiddle();
                                                                                          }
                                                                                      } else {
                                                                                          switch ($z) {
                                                                              9               case 1:
                                                                                                  fiddle();
                                                                                                  break;
                                                                              10              case 2:
                                                                                                  fiddle();
                                                                                                  break;
                                                                              11              case 3:
                                                                                                  fiddle();
                                                                                                  break;
                                                                                              default:
                                                                                                  fiddle();
                                                                                                  break;
                                                                                          }
                                                                                      }
                                                                                  }
                                                                              }

                                                                              Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                              The method asRelativeTime() has a Cyclomatic Complexity of 17. The configured cyclomatic complexity threshold is 10.
                                                                              Open

                                                                                  public function asRelativeTime($value, $referenceTime = null)
                                                                                  {
                                                                                      if ($value === null) {
                                                                                          return $this->nullDisplay;
                                                                                      }
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              CyclomaticComplexity

                                                                              Since: 0.1

                                                                              Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                              Example

                                                                              // Cyclomatic Complexity = 11
                                                                              class Foo {
                                                                              1   public function example() {
                                                                              2       if ($a == $b) {
                                                                              3           if ($a1 == $b1) {
                                                                                              fiddle();
                                                                              4           } elseif ($a2 == $b2) {
                                                                                              fiddle();
                                                                                          } else {
                                                                                              fiddle();
                                                                                          }
                                                                              5       } elseif ($c == $d) {
                                                                              6           while ($c == $d) {
                                                                                              fiddle();
                                                                                          }
                                                                              7        } elseif ($e == $f) {
                                                                              8           for ($n = 0; $n < $h; $n++) {
                                                                                              fiddle();
                                                                                          }
                                                                                      } else {
                                                                                          switch ($z) {
                                                                              9               case 1:
                                                                                                  fiddle();
                                                                                                  break;
                                                                              10              case 2:
                                                                                                  fiddle();
                                                                                                  break;
                                                                              11              case 3:
                                                                                                  fiddle();
                                                                                                  break;
                                                                                              default:
                                                                                                  fiddle();
                                                                                                  break;
                                                                                          }
                                                                                      }
                                                                                  }
                                                                              }

                                                                              Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                              The class Formatter has a coupling between objects value of 21. Consider to reduce the number of dependencies under 13.
                                                                              Open

                                                                              class Formatter extends Component
                                                                              {
                                                                                  /**
                                                                                   * @since 2.0.13
                                                                                   */
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              CouplingBetweenObjects

                                                                              Since: 1.1.0

                                                                              A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

                                                                              Example

                                                                              class Foo {
                                                                                  /**
                                                                                   * @var \foo\bar\X
                                                                                   */
                                                                                  private $x = null;
                                                                              
                                                                                  /**
                                                                                   * @var \foo\bar\Y
                                                                                   */
                                                                                  private $y = null;
                                                                              
                                                                                  /**
                                                                                   * @var \foo\bar\Z
                                                                                   */
                                                                                  private $z = null;
                                                                              
                                                                                  public function setFoo(\Foo $foo) {}
                                                                                  public function setBar(\Bar $bar) {}
                                                                                  public function setBaz(\Baz $baz) {}
                                                                              
                                                                                  /**
                                                                                   * @return \SplObjectStorage
                                                                                   * @throws \OutOfRangeException
                                                                                   * @throws \InvalidArgumentException
                                                                                   * @throws \ErrorException
                                                                                   */
                                                                                  public function process(\Iterator $it) {}
                                                                              
                                                                                  // ...
                                                                              }

                                                                              Source https://phpmd.org/rules/design.html#couplingbetweenobjects

                                                                              Missing class import via use statement (line '1658', column '46').
                                                                              Open

                                                                                              $this->_resourceBundle = new \ResourceBundle($this->locale, 'ICUDATA-unit');
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              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

                                                                              Missing class import via use statement (line '1633', column '21').
                                                                              Open

                                                                                      return (new \MessageFormatter($this->locale, $message))->format([
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              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

                                                                              The method normalizeDatetimeValue has a boolean flag argument $checkDateTimeInfo, which is a certain sign of a Single Responsibility Principle violation.
                                                                              Open

                                                                                  protected function normalizeDatetimeValue($value, $checkDateTimeInfo = false)
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              BooleanArgumentFlag

                                                                              Since: 1.4.0

                                                                              A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

                                                                              Example

                                                                              class Foo {
                                                                                  public function bar($flag = true) {
                                                                                  }
                                                                              }

                                                                              Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

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

                                                                                  public function asDecimal($value, $decimals = null, $options = [], $textOptions = [])
                                                                                  {
                                                                                      if ($value === null) {
                                                                                          return $this->nullDisplay;
                                                                                      }
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              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

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

                                                                                  public function asOrdinal($value)
                                                                                  {
                                                                                      if ($value === null) {
                                                                                          return $this->nullDisplay;
                                                                                      }
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              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

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

                                                                                  public function asInteger($value, $options = [], $textOptions = [])
                                                                                  {
                                                                                      if ($value === null) {
                                                                                          return $this->nullDisplay;
                                                                                      }
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              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

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

                                                                                  protected function normalizeDatetimeValue($value, $checkDateTimeInfo = false)
                                                                                  {
                                                                                      // checking for DateTime and DateTimeInterface is not redundant, DateTimeInterface is only in PHP>5.5
                                                                                      if ($value === null || $value instanceof DateTime || $value instanceof DateTimeInterface) {
                                                                                          // skip any processing
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              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

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

                                                                                  public function asSpellout($value)
                                                                                  {
                                                                                      if ($value === null) {
                                                                                          return $this->nullDisplay;
                                                                                      }
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              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

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

                                                                                  public function asScientific($value, $decimals = null, $options = [], $textOptions = [])
                                                                                  {
                                                                                      if ($value === null) {
                                                                                          return $this->nullDisplay;
                                                                                      }
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              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

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

                                                                                  public function asPercent($value, $decimals = null, $options = [], $textOptions = [])
                                                                                  {
                                                                                      if ($value === null) {
                                                                                          return $this->nullDisplay;
                                                                                      }
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              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

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

                                                                                  protected function normalizeDatetimeValue($value, $checkDateTimeInfo = false)
                                                                                  {
                                                                                      // checking for DateTime and DateTimeInterface is not redundant, DateTimeInterface is only in PHP>5.5
                                                                                      if ($value === null || $value instanceof DateTime || $value instanceof DateTimeInterface) {
                                                                                          // skip any processing
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              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

                                                                              Similar blocks of code found in 2 locations. Consider refactoring.
                                                                              Open

                                                                                  public function asShortSize($value, $decimals = null, $options = [], $textOptions = [])
                                                                                  {
                                                                                      if ($value === null) {
                                                                                          return $this->nullDisplay;
                                                                                      }
                                                                              Severity: Major
                                                                              Found in framework/i18n/Formatter.php and 1 other location - About 1 day to fix
                                                                              framework/i18n/Formatter.php on lines 1477..1516

                                                                              Duplicated Code

                                                                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                              Tuning

                                                                              This issue has a mass of 403.

                                                                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                              Refactorings

                                                                              Further Reading

                                                                              Similar blocks of code found in 2 locations. Consider refactoring.
                                                                              Open

                                                                                  public function asSize($value, $decimals = null, $options = [], $textOptions = [])
                                                                                  {
                                                                                      if ($value === null) {
                                                                                          return $this->nullDisplay;
                                                                                      }
                                                                              Severity: Major
                                                                              Found in framework/i18n/Formatter.php and 1 other location - About 1 day to fix
                                                                              framework/i18n/Formatter.php on lines 1421..1460

                                                                              Duplicated Code

                                                                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                              Tuning

                                                                              This issue has a mass of 403.

                                                                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                              Refactorings

                                                                              Further Reading

                                                                              Similar blocks of code found in 2 locations. Consider refactoring.
                                                                              Open

                                                                                  private function setFormatterTextAttribute($formatter, $attribute, $value, $source, $alternative)
                                                                                  {
                                                                                      if (!is_int($attribute)) {
                                                                                          throw new InvalidArgumentException(
                                                                                              "The $source array keys must be integers recognizable by NumberFormatter::setTextAttribute(). \""
                                                                              Severity: Major
                                                                              Found in framework/i18n/Formatter.php and 1 other location - About 3 hrs to fix
                                                                              framework/i18n/Formatter.php on lines 1893..1912

                                                                              Duplicated Code

                                                                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                              Tuning

                                                                              This issue has a mass of 150.

                                                                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                              Refactorings

                                                                              Further Reading

                                                                              Similar blocks of code found in 2 locations. Consider refactoring.
                                                                              Open

                                                                                  private function setFormatterIntAttribute($formatter, $attribute, $value, $source, $alternative)
                                                                                  {
                                                                                      if (!is_int($attribute)) {
                                                                                          throw new InvalidArgumentException(
                                                                                              "The $source array keys must be integers recognizable by NumberFormatter::setAttribute(). \""
                                                                              Severity: Major
                                                                              Found in framework/i18n/Formatter.php and 1 other location - About 3 hrs to fix
                                                                              framework/i18n/Formatter.php on lines 1843..1862

                                                                              Duplicated Code

                                                                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                              Tuning

                                                                              This issue has a mass of 150.

                                                                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                              Refactorings

                                                                              Further Reading

                                                                              Similar blocks of code found in 2 locations. Consider refactoring.
                                                                              Open

                                                                                  public function asSpellout($value)
                                                                                  {
                                                                                      if ($value === null) {
                                                                                          return $this->nullDisplay;
                                                                                      }
                                                                              Severity: Major
                                                                              Found in framework/i18n/Formatter.php and 1 other location - About 2 hrs to fix
                                                                              framework/i18n/Formatter.php on lines 1386..1402

                                                                              Duplicated Code

                                                                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                              Tuning

                                                                              This issue has a mass of 124.

                                                                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                              Refactorings

                                                                              Further Reading

                                                                              Similar blocks of code found in 2 locations. Consider refactoring.
                                                                              Open

                                                                                  public function asOrdinal($value)
                                                                                  {
                                                                                      if ($value === null) {
                                                                                          return $this->nullDisplay;
                                                                                      }
                                                                              Severity: Major
                                                                              Found in framework/i18n/Formatter.php and 1 other location - About 2 hrs to fix
                                                                              framework/i18n/Formatter.php on lines 1356..1372

                                                                              Duplicated Code

                                                                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                              Tuning

                                                                              This issue has a mass of 124.

                                                                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                              Refactorings

                                                                              Further Reading

                                                                              Avoid excessively long variable names like $numberFormatterTextOptions. Keep variable name length under 25.
                                                                              Open

                                                                                  public $numberFormatterTextOptions = [];
                                                                              Severity: Minor
                                                                              Found in framework/i18n/Formatter.php by phpmd

                                                                              LongVariable

                                                                              Since: 0.2

                                                                              Detects when a field, formal or local variable is declared with a long name.

                                                                              Example

                                                                              class Something {
                                                                                  protected $reallyLongIntName = -3; // VIOLATION - Field
                                                                                  public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                                                                                      $otherReallyLongName = -5; // VIOLATION - Local
                                                                                      for ($interestingIntIndex = 0; // VIOLATION - For
                                                                                           $interestingIntIndex < 10;
                                                                                           $interestingIntIndex++ ) {
                                                                                      }
                                                                                  }
                                                                              }

                                                                              Source https://phpmd.org/rules/naming.html#longvariable

                                                                              There are no issues that match your filters.

                                                                              Category
                                                                              Status