<commit_before><commit_msg>new static class for quick access to church info<commit_after><?php
/**
 * Created by PhpStorm.
 * User: georg
 * Date: 4/16/2017
 * Time: 9:43 PM
 */

namespace ChurchCRM\dto;

use ChurchCRM\Service\GeoCoderService;

class ChurchMetaData
{
    public static function getChurchName()
    {
        return SystemConfig::getValue('sChurchName');
    }

    public static function getChurchFullAddress()
    {
        $address = [];
        if (!empty(self::getChurchAddress())) {
            array_push($address, self::getChurchAddress());
        }

        if (!empty(self::getChurchCity())) {
            array_push($address, self::getChurchCity() . ',');
        }

        if (!empty(self::getChurchState())) {
            array_push($address, self::getChurchState());
        }

        if (!empty(self::getChurchZip())) {
            array_push($address, self::getChurchZip());
        }
        if (!empty(self::getChurchCountry())) {
            array_push($address, self::getChurchCountry());
        }

        return implode(' ', $address);
    }

    public static function getChurchAddress()
    {
        return SystemConfig::getValue('sChurchAddress');
    }

    public static function getChurchCity()
    {
        return SystemConfig::getValue('sChurchCity');
    }

    public static function getChurchState()
    {
        return SystemConfig::getValue('sChurchState');
    }

    public static function getChurchZip()
    {
        return SystemConfig::getValue('sChurchZip');
    }

    public static function getChurchCountry()
    {
        return SystemConfig::getValue('sChurchCountry');
    }

    public static function getChurchLatitude()
    {
        if (empty(SystemConfig::getValue('nChurchLatitude'))) {
            self::updateLatLng();
        }
        return SystemConfig::getValue('nChurchLatitude');
    }

    public static function getChurchLongitude()
    {
        if (empty(SystemConfig::getValue('nChurchLongitude'))) {
            self::updateLatLng();
        }
        return SystemConfig::getValue('nChurchLongitude');
    }

    private static function updateLatLng()
    {
        if (!empty(self::getChurchFullAddress())) {
            $geoCode = new GeoCoderService();
            $latLng = $geoCode->getLatLong(self::getChurchFullAddress());
            if (!empty($latLng['Latitude']) && !empty($latLng['Longitude'])) {
                SystemConfig::setValue('nChurchLatitude', $latLng['Latitude']);
                SystemConfig::setValue('nChurchLongitude', $latLng['Longitude']);
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.13603082851637766, 'fraction_numerical': 0.0038535645472061657, 'mean_word_length': 2.698005698005698, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '4609208', 'n_tokens_mistral': 755, 'n_tokens_neox': 699, 'n_words': 125}