Fibinger Ádám
2020-05-01 7a397279805473a76251db4821b7a8c0a76a554c
EOG/Models/TeamList.php
@@ -11,9 +11,7 @@
    */
   protected $teams = [];
   private $requiredRawFields = ['name', 'seed', 'status'];
   public function fromJson(string $jsonString) : int
   public function fromJson(string $jsonString): int
   {
      $rawData = json_decode($jsonString, true);
@@ -31,16 +29,21 @@
      foreach ($rawData as $key => $team)
      {
         $rawKeys = array_keys($team);
         if (count(array_intersect($rawKeys, $this->requiredRawFields)) != 3)
         $players = [];
         if (is_array($team['players']))
         {
            continue;
            foreach ($team['players'] as $player)
            {
               if (!empty($player['inGameName']))
               {
                  $players[] = $player['inGameName'];
               }
            }
         }
         if ($team['status'] == 'checkedIn')
         {
            $this->teams[] = $team;
         }
         $this->teams[] = [
            'name'    => $team['name'],
            'players' => $players
         ];
      }
      return (bool)count($this->teams);