<commit_before><?php
namespace deka6pb\geocoder\objects;
use deka6pb\geocoder\abstraction\ObjectAbstract;
use deka6pb\geocoder\Point;
use yii\helpers\ArrayHelper;
use yii\helpers\VarDumper;
class YandexObject extends ObjectAbstract
{
    public function initialization($config = [])
    {
        if (false === is_array($config)) {
            $config = ArrayHelper::toArray($config);
        }
        $object = ArrayHelper::getValue($config, 'GeoObject');
        $point = ArrayHelper::getValue($object, 'Point.pos', '');
        $point = explode(' ', $point);
        $metaData = ArrayHelper::getValue($object, 'metaDataProperty.GeocoderMetaData', []);
        $area = ArrayHelper::getValue($metaData, 'AddressDetails.Country.AdministrativeArea.SubAdministrativeArea')
                    ? ArrayHelper::getValue($metaData, 'AddressDetails.Country.AdministrativeArea.SubAdministrativeArea')
                    : ArrayHelper::getValue($metaData, 'AddressDetails.Country.AdministrativeArea');

        $locality = ArrayHelper::getValue($area, 'Locality');

        $thoroughfare = $this->processThoroughfare($locality);

        // Получаем полный адрес
        $this->address = ArrayHelper::getValue($metaData, 'text');
        // Получаем город
        $this->data['city'] = ArrayHelper::getValue($area, 'Locality.LocalityName');
        $this->city = $this->data['city'];
        // Получаем округ/область
        $this->data['area'] = ArrayHelper::getValue($metaData, 'AddressDetails.Country.AdministrativeArea.AdministrativeAreaName');
        // Страну
        $this->data['country'] = ArrayHelper::getValue($metaData, 'AddressDetails.Country.CountryName');
        // Код страны
        $this->data['countrySlug'] = ArrayHelper::getValue($metaData, 'AddressDetails.Country.CountryCode');
        // Получаем ветку/улицу
        $this->data['thoroughfare'] = ArrayHelper::getValue($thoroughfare, 'ThoroughfareName');
        $this->data['street'] = $this->data['thoroughfare'];
        // Получаем номер дома
        $this->data['house'] = ArrayHelper::getValue($thoroughfare, 'Premise.PremiseNumber');
        $this->locality_type = strripos($this->city, 'деревн') === false
            ? self::LOCALITY_TYPE_CITY
            : self::LOCALITY_TYPE_VILLAGE;
        $this->name = ArrayHelper::getValue($object, 'name', '');
        $this->type = ArrayHelper::getValue($metaData, 'kind', '');
        $this->description = ArrayHelper::getValue($object, 'description', '');
        $this->point = new Point(['latitude' => $point[1], 'longitude' => $point[0]]);
    }

    public function processThoroughfare($locality)
    {
        while(!empty($locality['DependentLocality'])) {
            $locality = $locality['DependentLocality'];
        }


        if(!empty($locality['Thoroughfare'])) {
            return $locality['Thoroughfare'];
        }

        return null;
    }
}<commit_msg>ad sub_area in Yandex Object<commit_after><?php
namespace deka6pb\geocoder\objects;

use deka6pb\geocoder\abstraction\ObjectAbstract;
use deka6pb\geocoder\Point;
use yii\helpers\ArrayHelper;
use yii\helpers\VarDumper;

class YandexObject extends ObjectAbstract
{
    public function initialization($config = [])
    {
        if (false === is_array($config)) {
            $config = ArrayHelper::toArray($config);
        }
        $object = ArrayHelper::getValue($config, 'GeoObject');
        $point = ArrayHelper::getValue($object, 'Point.pos', '');
        $point = explode(' ', $point);
        $metaData = ArrayHelper::getValue($object, 'metaDataProperty.GeocoderMetaData', []);
        $administrative = ArrayHelper::getValue($metaData, 'AddressDetails.Country.AdministrativeArea.SubAdministrativeArea')
            ? ArrayHelper::getValue($metaData, 'AddressDetails.Country.AdministrativeArea.SubAdministrativeArea')
            : ArrayHelper::getValue($metaData, 'AddressDetails.Country.AdministrativeArea');

        $locality = ArrayHelper::getValue($administrative, 'Locality');

        $thoroughfare = $this->processThoroughfare($locality);

        // Получаем полный адрес
        $this->address = ArrayHelper::getValue($metaData, 'text');
        // Получаем город
        $this->data['city'] = ArrayHelper::getValue($administrative, 'Locality.LocalityName');
        $this->city = $this->data['city'];
        // Получаем округ/область
        $this->data['area'] = ArrayHelper::getValue($metaData,
            'AddressDetails.Country.AdministrativeArea.AdministrativeAreaName');

        $this->data['sub_area'] = ArrayHelper::getValue($metaData,
            'AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.SubAdministrativeAreaName');
        // Страну
        $this->data['country'] = ArrayHelper::getValue($metaData, 'AddressDetails.Country.CountryName');
        // Код страны
        $this->data['countrySlug'] = ArrayHelper::getValue($metaData, 'AddressDetails.Country.CountryCode');
        // Получаем ветку/улицу
        $this->data['thoroughfare'] = ArrayHelper::getValue($thoroughfare, 'ThoroughfareName');
        $this->data['street'] = $this->data['thoroughfare'];
        // Получаем номер дома
        $this->data['house'] = ArrayHelper::getValue($thoroughfare, 'Premise.PremiseNumber');
        $this->locality_type = strripos($this->city, 'деревн') === false
            ? self::LOCALITY_TYPE_CITY
            : self::LOCALITY_TYPE_VILLAGE;
        $this->name = ArrayHelper::getValue($object, 'name', '');
        $this->type = ArrayHelper::getValue($metaData, 'kind', '');
        $this->description = ArrayHelper::getValue($object, 'description', '');
        $this->point = new Point(['latitude' => $point[1], 'longitude' => $point[0]]);
    }

    public function processThoroughfare($locality)
    {
        while (!empty($locality['DependentLocality'])) {
            $locality = $locality['DependentLocality'];
        }


        if (!empty($locality['Thoroughfare'])) {
            return $locality['Thoroughfare'];
        }

        return null;
    }
}
{'fraction_non_alphanumeric': 0.15700282438943347, 'fraction_numerical': 0.001661405549094534, 'mean_word_length': 3.5026178010471205, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 44, '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': '6578841', 'n_tokens_mistral': 1753, 'n_tokens_neox': 1761, 'n_words': 247}