syntaxerrors/Steam

View on GitHub
src/Syntax/SteamApi/Containers/Player.php

Summary

Maintainability
A
2 hrs
Test Coverage
A
100%

Method __construct has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function __construct($player)
    {
        $this->steamId                  = $player->steamid;
        $this->steamIds                 = (new Id((int)$this->steamId));
        $this->communityVisibilityState = $player->communityvisibilitystate;
Severity: Minor
Found in src/Syntax/SteamApi/Containers/Player.php - About 1 hr to fix

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

        protected function getLocation(): \stdClass
        {
            $countriesFile = json_decode(\file_get_contents(__DIR__ . '/../Resources/countries.json'), null, 512, JSON_THROW_ON_ERROR);
            $result        = new \stdClass;
    
    
    Severity: Minor
    Found in src/Syntax/SteamApi/Containers/Player.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

    Line exceeds 120 characters; contains 128 characters
    Open

                    if (isset($countriesFile->{$this->locCountryCode}->states->{$this->locStateCode}->cities->{$this->locCityId})) {

    Line exceeds 120 characters; contains 127 characters
    Open

                if ($this->locStateCode != null && isset($countriesFile->{$this->locCountryCode}->states->{$this->locStateCode})) {

    Line exceeds 120 characters; contains 215 characters
    Open

                if ($this->locCityId != null && isset($countriesFile->{$this->locCountryCode}->states->{$this->locStateCode}) && ! empty($countriesFile->{$this->locCountryCode}->states->{$this->locStateCode}->cities)) {

    Line exceeds 120 characters; contains 141 characters
    Open

                        $result->city = $countriesFile->{$this->locCountryCode}->states->{$this->locStateCode}->cities->{$this->locCityId}->name;

    Line exceeds 120 characters; contains 131 characters
    Open

            $countriesFile = json_decode(\file_get_contents(__DIR__ . '/../Resources/countries.json'), null, 512, JSON_THROW_ON_ERROR);

    Expected 1 space after closing parenthesis; found 9
    Open

            if (! empty(array_filter($gameDetails)))

    Space before opening parenthesis of function call prohibited
    Open

            return match ($personaState) {

    Line indented incorrectly; expected 8 spaces, found 12
    Open

                default => 'Unknown',

    There are no issues that match your filters.

    Category
    Status