bravesheep/dogmatist

View on GitHub
src/Sampler.php

Summary

Maintainability
D
2 days
Test Coverage

Function sample has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    public function sample(Builder $builder, UniqueArrayObject $parent = null)
    {
        $data = new UniqueArrayObject($parent);
        $faker = $this->dogmatist->getFaker();
        foreach ($builder->getFields() as $field) {
Severity: Minor
Found in src/Sampler.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

File Sampler.php has 279 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Bravesheep\Dogmatist;

use Bravesheep\Dogmatist\Exception\SampleException;
Severity: Minor
Found in src/Sampler.php - About 2 hrs to fix

    Function setObjectProperty has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        private function setObjectProperty($obj, $key, $value, Builder $builder)
        {
            if ($value instanceof ReplacableArray) {
                foreach ($value->data as &$subval) {
                    foreach ($subval->fields as $field) {
    Severity: Minor
    Found in src/Sampler.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 sampleField has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        private function sampleField(Field $field, UniqueArrayObject $data)
        {
            $faker = $this->dogmatist->getFaker();
            $type = $field->getType();
            $value = null;
    Severity: Minor
    Found in src/Sampler.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 replaceLinksInObject has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        private function replaceLinksInObject($obj, Builder $builder)
        {
            foreach (get_object_vars($obj) as $key => $value) {
                if ($value instanceof ReplacableArray) {
                    foreach ($value->data as &$subval) {
    Severity: Minor
    Found in src/Sampler.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 replaceLinksInArray has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        private function replaceLinksInArray(array $data, Builder $builder)
        {
            foreach ($data as $key => &$value) {
                if ($value instanceof ReplacableArray) {
                    foreach ($value->data as &$subval) {
    Severity: Minor
    Found in src/Sampler.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 alignArgs has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        private function alignArgs(\ReflectionMethod $constructor, array $data, ConstructorBuilder $builder)
        {
            if ($builder->isPositional()) {
                $aligned = $data;
            } else {
    Severity: Minor
    Found in src/Sampler.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

    Method setObjectProperty has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function setObjectProperty($obj, $key, $value, Builder $builder)
        {
            if ($value instanceof ReplacableArray) {
                foreach ($value->data as &$subval) {
                    foreach ($subval->fields as $field) {
    Severity: Minor
    Found in src/Sampler.php - About 1 hr to fix

      Method sample has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function sample(Builder $builder, UniqueArrayObject $parent = null)
          {
              $data = new UniqueArrayObject($parent);
              $faker = $this->dogmatist->getFaker();
              foreach ($builder->getFields() as $field) {
      Severity: Minor
      Found in src/Sampler.php - About 1 hr to fix

        Method sampleField has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function sampleField(Field $field, UniqueArrayObject $data)
            {
                $faker = $this->dogmatist->getFaker();
                $type = $field->getType();
                $value = null;
        Severity: Minor
        Found in src/Sampler.php - About 1 hr to fix

          Function constructObject has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              private function constructObject(\ReflectionClass $refl, Builder $builder)
              {
                  $constructor = $refl->getConstructor();
                  $obj = null;
                  if (null === $constructor || $constructor->getNumberOfParameters() === 0) {
          Severity: Minor
          Found in src/Sampler.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

          There are no issues that match your filters.

          Category
          Status