LeagueWrap\StaticOptimizer::setStaticInfo PHP Method

setStaticInfo() public method

Uses the static api to get all the static information we need that have already been optimized.
public setStaticInfo ( Staticdata $staticData ) : void
$staticData LeagueWrap\Api\Staticdata
return void
    public function setStaticInfo(Staticdata $staticData)
    {
        $results = [];
        foreach ($this->requests as $source => $ids) {
            $result = [];
            $method = 'get' . ucfirst($source);
            if (count($ids) > 1) {
                // group up the calls
                if (preg_match('/(?<![aeiou])y$/', $method)) {
                    // if last char is 'y' preceeded by a vowel replace for plural
                    $method = substr($method, 0, -1) . 'ie';
                }
                $method .= 's';
                $data = $staticData->{$method}();
                foreach ($ids as $id) {
                    $result[$id] = $data[$id];
                }
            } else {
                $id = reset($ids);
                $data = $staticData->{$method}($id);
                $result[$id] = $data;
            }
            $results[$source] = $result;
        }
        $this->results = $results;
    }