src/Syntax/SteamApi/Containers/Player.php
Method __construct
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function __construct($player)
{
$this->steamId = $player->steamid;
$this->steamIds = (new Id((int)$this->steamId));
$this->communityVisibilityState = $player->communityvisibilitystate;
Function getLocation
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
protected function getLocation(): \stdClass
{
$countriesFile = json_decode(\file_get_contents(__DIR__ . '/../Resources/countries.json'), null, 512, JSON_THROW_ON_ERROR);
$result = new \stdClass;
- Read upRead up
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
Open
if (isset($countriesFile->{$this->locCountryCode}->states->{$this->locStateCode}->cities->{$this->locCityId})) {
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
Open
if ($this->locStateCode != null && isset($countriesFile->{$this->locCountryCode}->states->{$this->locStateCode})) {
- Exclude checks
Line exceeds 120 characters; contains 215 characters Open
Open
if ($this->locCityId != null && isset($countriesFile->{$this->locCountryCode}->states->{$this->locStateCode}) && ! empty($countriesFile->{$this->locCountryCode}->states->{$this->locStateCode}->cities)) {
- Exclude checks
Line exceeds 120 characters; contains 141 characters Open
Open
$result->city = $countriesFile->{$this->locCountryCode}->states->{$this->locStateCode}->cities->{$this->locCityId}->name;
- Exclude checks
Line exceeds 120 characters; contains 131 characters Open
Open
$countriesFile = json_decode(\file_get_contents(__DIR__ . '/../Resources/countries.json'), null, 512, JSON_THROW_ON_ERROR);
- Exclude checks
Expected 1 space after closing parenthesis; found 9 Open
Open
if (! empty(array_filter($gameDetails)))
- Exclude checks
Space before opening parenthesis of function call prohibited Open
Open
return match ($personaState) {
- Exclude checks
Line indented incorrectly; expected 8 spaces, found 12 Open
Open
default => 'Unknown',
- Exclude checks