/** * Creates a player object with the given data * @param array $data an associative array to fill up the members of the * player class * @return Player a player object with the data given as it's members */ public static function create(array $data) : Player { $player = new Player(); parent::fill($data, $player); if (is_array($player->clan)) { $player->clan = Clan::create($player->clan); } if (is_array($player->league)) { $player->league = League::create($player->league); } return $player; }
/** * Creates a clan object with the given data * @param array $data an associative array to fill up the members of the * clan class * @return Clan a clan object with the data given as it's members */ public static function create(array $data) : Clan { $clan = new Clan(); parent::fill($data, $clan); if (is_array($clan->location)) { $clan->location = Location::create($clan->location); } if (is_array($clan->memberList)) { $members = []; foreach ($clan->memberList as $member) { $members[] = Player::create($member); } $clan->memberList = $members; } return $clan; }
/** * Creates a league object with the given data * @param array $data an associative array to fill up the members of the * league class * @return League a league object with the data given as it's members */ public static function create(array $data) : League { $league = new League(); parent::fill($data, $league); return $league; }
/** * Creates a location object with the given data * @param array $data an associative array to fill up the members of the * location class * @return Location a location object with the data given as it's members */ public static function create(array $data) : Location { $location = new Location(); parent::fill($data, $location); return $location; }