Fibinger Ádám
2020-05-01 7a397279805473a76251db4821b7a8c0a76a554c
Csapat import - Battlefy Edition
1 files modified
21 ■■■■■ changed files
EOG/Models/TeamList.php 21 ●●●●● patch | view | raw | blame | history
EOG/Models/TeamList.php
@@ -11,8 +11,6 @@
     */
    protected $teams = [];
    private $requiredRawFields = ['name', 'seed', 'status'];
    public function fromJson(string $jsonString) : int
    {
        $rawData = json_decode($jsonString, true);
@@ -31,17 +29,22 @@
        foreach ($rawData as $key => $team)
        {
            $rawKeys = array_keys($team);
            if (count(array_intersect($rawKeys, $this->requiredRawFields)) != 3)
            $players = [];
            if (is_array($team['players']))
            {
                continue;
            }
            if ($team['status'] == 'checkedIn')
                foreach ($team['players'] as $player)
            {
                $this->teams[] = $team;
                    if (!empty($player['inGameName']))
                    {
                        $players[] = $player['inGameName'];
            }
        }
            }
            $this->teams[] = [
                'name'    => $team['name'],
                'players' => $players
            ];
        }
        return (bool)count($this->teams);
    }