Jelle-S/TheSportsDb

View on GitHub

Showing 92 of 92 total issues

Function sanitizeProperty has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  public function sanitizeProperty(\stdClass &$object, FactoryContainerInterface $factoryContainer) {
    if (($entityType = $this->getEntityType()) && isset($object->{$this->getName()})) {
      $value = &$object->{$this->getName()};
      if ($this->isArray()) {
        foreach ($value as &$val) {
Severity: Minor
Found in src/PropertyMapper/PropertyDefinition.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 Event has 50 public methods and attributes. Consider reducing the number of public items to less than 50.
Open

class Event extends Entity implements EventInterface {

  /**
   * {@inheritdoc}
   */
Severity: Minor
Found in src/Entity/Event.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 raw has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  public function raw() {
    if (isset($this->_raw)) {
      return $this->_raw;
    }
    $this->_raw = new \stdClass();
Severity: Minor
Found in src/Entity/Entity.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 initPropertyMap has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  protected function initPropertyMap($entityType) {
    $this->propertyMaps[$entityType] = new Map();
    $entityManager = $this;
    foreach ($this->getPropertyMapDefinition($entityType)->getPropertyMaps() as $map) {
      $args = [
Severity: Minor
Found in src/Entity/EntityManager.php - About 1 hr to fix

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

      public function raw() {
        if ($this->entity) {
          $this->_raw = $this->entity->raw();
          return $this->_raw;
        }
    Severity: Minor
    Found in src/Entity/Proxy/Proxy.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 initPropertyMap has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      protected function initPropertyMap($entityType) {
        $this->propertyMaps[$entityType] = new Map();
        $entityManager = $this;
        foreach ($this->getPropertyMapDefinition($entityType)->getPropertyMaps() as $map) {
          $args = [
    Severity: Minor
    Found in src/Entity/EntityManager.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

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

      public function load() {
        $teamData = $this->sportsDbClient->doRequest('lookupteam.php', array('id' => $this->properties->id));
        if (isset($teamData->teams)) {
          $this->update($this->entityManager->mapProperties(reset($teamData->teams), $this->getEntityType()));
          return;
    Severity: Major
    Found in src/Entity/Proxy/TeamProxy.php and 3 other locations - About 45 mins to fix
    src/Entity/Proxy/EventProxy.php on lines 21..28
    src/Entity/Proxy/LeagueProxy.php on lines 21..28
    src/Entity/Proxy/PlayerProxy.php on lines 21..28

    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 96.

    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 4 locations. Consider refactoring.
    Open

      public function load() {
        $leagueData = $this->sportsDbClient->doRequest('lookupleague.php', array('id' => $this->properties->id));
        if (isset($leagueData->leagues)) {
          $this->update($this->entityManager->mapProperties(reset($leagueData->leagues), $this->getEntityType()));
          return;
    Severity: Major
    Found in src/Entity/Proxy/LeagueProxy.php and 3 other locations - About 45 mins to fix
    src/Entity/Proxy/EventProxy.php on lines 21..28
    src/Entity/Proxy/PlayerProxy.php on lines 21..28
    src/Entity/Proxy/TeamProxy.php on lines 21..28

    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 96.

    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 4 locations. Consider refactoring.
    Open

      public function load() {
        $eventData = $this->sportsDbClient->doRequest('lookupevent.php', array('id' => $this->properties->id));
        if (isset($eventData->events)) {
          $this->update($this->entityManager->mapProperties(reset($eventData->events), $this->getEntityType()));
          return;
    Severity: Major
    Found in src/Entity/Proxy/EventProxy.php and 3 other locations - About 45 mins to fix
    src/Entity/Proxy/LeagueProxy.php on lines 21..28
    src/Entity/Proxy/PlayerProxy.php on lines 21..28
    src/Entity/Proxy/TeamProxy.php on lines 21..28

    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 96.

    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 4 locations. Consider refactoring.
    Open

      public function load() {
        $playerData = $this->sportsDbClient->doRequest('lookupplayer.php', array('id' => $this->properties->id));
        if (isset($playerData->players)) {
          $this->update($this->entityManager->mapProperties(reset($playerData->players), $this->getEntityType()));
          return;
    Severity: Major
    Found in src/Entity/Proxy/PlayerProxy.php and 3 other locations - About 45 mins to fix
    src/Entity/Proxy/EventProxy.php on lines 21..28
    src/Entity/Proxy/LeagueProxy.php on lines 21..28
    src/Entity/Proxy/TeamProxy.php on lines 21..28

    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 96.

    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

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

      public static function transform($value, $context, EntityManagerInterface $entityManager, $entityType, $idName, array $contextPropertyMap = array()) {
    Severity: Minor
    Found in src/Entity/Entity.php - About 45 mins to fix

      Missing class import via use statement (line '35', column '17').
      Open

            throw new \Exception('No repository registered for ' . $entityType);

      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 '114', column '15').
      Open

          throw new \Exception('No repository container set.');
      Severity: Minor
      Found in src/Entity/EntityManager.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 '141', column '17').
      Open

            throw new \Exception('Class ' . $proxyClass . 'not found.');
      Severity: Minor
      Found in src/Entity/EntityManager.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 '175', column '19').
      Open

          $mapped = new \stdClass();
      Severity: Minor
      Found in src/Entity/EntityManager.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 '132', column '25').
      Open

            $realClass = (new \ReflectionClass(static::class))->getNamespaceName() . '\\' . ucfirst($entityType);
      Severity: Minor
      Found in src/Entity/EntityManager.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 '209', column '23').
      Open

          $reflection = new \ReflectionClass($this->getClass($entityType));
      Severity: Minor
      Found in src/Entity/EntityManager.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 '53', column '13').
      Open

              new \ReflectionClass($this->entityManager->getClass($entityType, 'proxy'))
      Severity: Minor
      Found in src/Entity/Factory/Factory.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 '54', column '15').
      Open

              : new \ReflectionClass($this->entityManager->getClass($entityType));
      Severity: Minor
      Found in src/Entity/Factory/Factory.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 '91', column '17').
      Open

            throw new \Exception('Factory container already set.');
      Severity: Minor
      Found in src/Entity/EntityManager.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

      Severity
      Category
      Status
      Source
      Language