<commit_before><?php namespace WowApi\Services;

use WowApi\Components\Resources\Battlegroup;
use WowApi\Components\Resources\Talents\Branch;
use WowApi\Components\Resources\Talents\Glyph;
use WowApi\Components\Resources\Talents\Spec;
use WowApi\Components\Resources\Talents\Talent;
use WowApi\Components\Resources\Talents\TalentTree;
use GuzzleHttp\Exception\ClientException;
use WowApi\Exceptions\IllegalArgumentException;
use WowApi\Exceptions\WowApiException;

/**
 * Resource services
 *
 * @package     Services
 * @author      <NAME>
 * @version     1.0.0
 */
class ResourceService extends BaseService {

    /**
     * Get Battlegroups based on current region
     *
     * @return array
     * @throws IllegalArgumentException
     * @throws WowApiException
     */
    public function getBattlegroups() {
        $request = parent::createRequest('GET', 'data/battlegroups/');

        try {
            $response = parent::doRequest($request);
        } catch (ClientException $e) {
            throw parent::toWowApiException($e);
        }

        return Battlegroup::getBattlegroups($response->getBody());
    }

    /**
     * Get TalentTree
     *
     * @return TalentTree
     * @throws IllegalArgumentException
     * @throws WowApiException
     */
    public function getTalentTree() {
        $request = parent::createRequest('GET', 'data/talents');

        try {
            $response = parent::doRequest($request);
        } catch (ClientException $e) {
            throw parent::toWowApiException($e);
        }

        $buildTree = $this->buildTalentTree(json_decode($response->getBody()));

        $talentTree = new TalentTree();
        $talentTree->tree = $buildTree;

        return $talentTree;
    }

    /**
     * Build the TalentTree
     *
     * @param object $talentTree
     * @return array
     */
    private function buildTalentTree($talentTree) {
        $branches = [];

        foreach ($talentTree as $branch) {
            $branchObj = new Branch();
            $branchObj->glyphs = $this->getGlyphs($branch->glyphs);
            $branchObj->talents = $this->getTalents($branch->talents);
            $branchObj->class = $branch->class;
            $branchObj->specs = $this->getSpecs($branch->specs);

            $branches[] = $branchObj;
        }

        return $branches;
    }

    /**
     * Get the Glyphs for each Branch
     *
     * @param array $glyphArr
     * @return array
     */
    private function getGlyphs($glyphArr = []) {
        $returnArr = [];

        foreach ($glyphArr as $glyph) {
            $returnArr[] = new Glyph(json_encode($glyph));
        }

        return $returnArr;
    }

    /**
     * Get the tiers and their Talents
     *
     * @param array $tierArr
     * @return array
     */
    private function getTalents($tierArr = []) {
        $returnArr = [];

        foreach ($tierArr as $tier) {
            $tierArr = [];

            foreach ($tier as $tierTalents) {
                $talentArr = [];

                foreach ($tierTalents as $talent) {
                    $talentArr[] = new Talent(json_encode($talent));
                }

                $tierArr[] = $talentArr;
            }

            $returnArr[] = $tierArr;
        }

        return $returnArr;
    }<commit_msg>correct talent array name and spacing<commit_after><?php namespace WowApi\Services;

use WowApi\Components\Resources\Battlegroup;
use WowApi\Components\Resources\Talents\Branch;
use WowApi\Components\Resources\Talents\Glyph;
use WowApi\Components\Resources\Talents\Spec;
use WowApi\Components\Resources\Talents\Talent;
use WowApi\Components\Resources\Talents\TalentTree;
use GuzzleHttp\Exception\ClientException;
use WowApi\Exceptions\IllegalArgumentException;
use WowApi\Exceptions\WowApiException;

/**
 * Resource services
 *
 * @package     Services
 * @author      <NAME>
 * @version     1.0.0
 */
class ResourceService extends BaseService {

    /**
     * Get Battlegroups based on current region
     *
     * @return array
     * @throws IllegalArgumentException
     * @throws WowApiException
     */
    public function getBattlegroups() {
        $request = parent::createRequest('GET', 'data/battlegroups/');

        try {
            $response = parent::doRequest($request);
        } catch (ClientException $e) {
            throw parent::toWowApiException($e);
        }

        return Battlegroup::getBattlegroups($response->getBody());
    }

    /**
     * Get TalentTree
     *
     * @return TalentTree
     * @throws IllegalArgumentException
     * @throws WowApiException
     */
    public function getTalentTree() {
        $request = parent::createRequest('GET', 'data/talents');

        try {
            $response = parent::doRequest($request);
        } catch (ClientException $e) {
            throw parent::toWowApiException($e);
        }

        $buildTree = $this->buildTalentTree(json_decode($response->getBody()));

        $talentTree = new TalentTree();
        $talentTree->tree = $buildTree;

        return $talentTree;
    }

    /**
     * Build the TalentTree
     *
     * @param object $talentTree
     * @return array
     */
    private function buildTalentTree($talentTree) {
        $branches = [];

        foreach ($talentTree as $branch) {
            $branchObj = new Branch();
            $branchObj->glyphs = $this->getGlyphs($branch->glyphs);
            $branchObj->talents = $this->getTalents($branch->talents);
            $branchObj->class = $branch->class;
            $branchObj->specs = $this->getSpecs($branch->specs);

            $branches[] = $branchObj;
        }

        return $branches;
    }

    /**
     * Get the Glyphs for each Branch
     *
     * @param array $glyphArr
     * @return array
     */
    private function getGlyphs($glyphArr = []) {
        $returnArr = [];

        foreach ($glyphArr as $glyph) {
            $returnArr[] = new Glyph(json_encode($glyph));
        }

        return $returnArr;
    }

    /**
     * Get the tiers and their Talents
     *
     * @param array $tierArr
     * @return array
     */
    private function getTalents($tierArr = []) {
        $returnArr = [];

        foreach ($tierArr as $tier) {
            $rTierArr = [];
            foreach ($tier as $tierTalents) {
                $talentArr = [];
                foreach ($tierTalents as $talent) {
                    $talentArr[] = new Talent(json_encode($talent));
                }
                $rTierArr[] = $talentArr;
            }
            $returnArr[] = $rTierArr;
        }

        return $returnArr;
    }
{'fraction_non_alphanumeric': 0.12490525996665151, 'fraction_numerical': 0.0009095043201455207, 'mean_word_length': 2.1479007633587788, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '658911', 'n_tokens_mistral': 1988, 'n_tokens_neox': 1858, 'n_words': 375}