/** * Iterates through a list of returned objects form the API, and "casts" them as * modal classes * for example, $bb->tournament->list_my() returns an array, each element being an instance of BBTournament, * so you could for example, delete all of your 'SC2' Tournaments like this (be careful, this can be dangerous and irreversable!) * * * $tournies = $bb->tournament->list_my('SC2'); * foreach($tournies as &$tournament) { * $tournament->delete(); * } * * @ignore * * @param array $list * @param string $class * By default this method will use cast each object into whatever the current class is * However, this can be overridden by defining the class manually here by setting <$class> * Just beware that it must be a Model class * @return BBModel[] $class */ protected function wrap_list($list, $class = null) { //Determine which class to instantiate if not provided if (is_null($class)) { $class = $this->get_class_name(); } //Add instantiated modals of each element into a new output array $out = array(); foreach ($list as $object) { $out[] = $this->bb->get_model($class, $object); } return $out; }