Destiny\Grimoire::gCards PHP Method

gCards() protected method

protected gCards ( )
    protected function gCards()
    {
        $collection = $this->newCollection();
        foreach ($this->themeCollection as $theme) {
            foreach ($theme->pageCollection as $page) {
                foreach ($page->cardBriefs as $card) {
                    $collection->put($card->cardId, $card);
                }
            }
        }
        return $collection->sort(function (Card $a, Card $b) {
            if ($a->hasRanks()) {
                if ($b->hasRanks()) {
                    if ($a->percent != $b->percent) {
                        return $a->percent > $b->percent ? -1 : +1;
                    }
                    goto name;
                }
                return -1;
            }
            if ($b->hasRanks()) {
                if ($a->hasRanks()) {
                    if ($a->percent != $b->percent) {
                        return $a->percent > $b->percent ? +1 : -1;
                    }
                    goto name;
                }
                return +1;
            }
            name:
            if ($a->active && !$b->active) {
                return -1;
            } elseif ($b->active && !$a->active) {
                return +1;
            }
            return strcmp($a->cardName, $b->cardName);
        });
    }