<commit_before><?php

namespace Galahad\LaravelAddressing;

use CommerceGuys\Addressing\Model\Subdivision;

/**
 * Class Locality
 *
 * @package Galahad\LaravelAddressing
 * @author <NAME> <<EMAIL>>
 */
class Locality
{
	/**
	 * @var AdministrativeArea
	 */
	protected $administrativeArea;

	/**
	 * @var string
	 */
	protected $name;

	/**
	 * @var string
	 */
	protected $locale;

	/**
	 * The constructor method
	 *
	 * @param AdministrativeArea $administrativeArea
	 */
	public function __construct(AdministrativeArea $administrativeArea)
	{
		$this->administrativeArea = $administrativeArea;
	}

	/**
	 * Get all localities from a given Administrative Area
	 *
	 * @return LocalityCollection
	 */
	public function getAll()
	{
		$subdivision = $this->administrativeArea->getSubdivision();
		$list = new LocalityCollection();
		$children = $subdivision->getChildren();
		/** @var Subdivision $child */
		foreach ($children as $child) {
			$locality = new static($this->administrativeArea);
			$locality->setName($child->getName());
			$locality->setLocale($child->getLocale());
			$list->insert($locality);
		}

		return $list;
	}

	/**
	 * Get the locality name
	 *
	 * @return string
	 */
	public function getName()
	{
		return $this->name;
	}

	/**
	 * Set the locality name
	 *
	 * @param string $name
	 */
	public function setName($name)
	{
		$this->name = $name;
	}

	/**
	 * Get the locality locale
	 *
	 * @return string
	 */
	public function getLocale()
	{
		return $this->locale;
	}

	/**
	 * Set the locality locale<commit_msg>Get a locality object by its name<commit_after><?php

namespace Galahad\LaravelAddressing;

use CommerceGuys\Addressing\Model\Subdivision;

/**
 * Class Locality
 *
 * @package Galahad\LaravelAddressing
 * @author <NAME> <<EMAIL>>
 */
class Locality
{
	/**
	 * @var AdministrativeArea
	 */
	protected $administrativeArea;

	/**
	 * @var string
	 */
	protected $name;

	/**
	 * @var string
	 */
	protected $locale;

	/**
	 * The constructor method
	 *
	 * @param AdministrativeArea $administrativeArea
	 */
	public function __construct(AdministrativeArea $administrativeArea)
	{
		$this->administrativeArea = $administrativeArea;
	}

	/**
	 * Get all localities from a given Administrative Area
	 *
	 * @return LocalityCollection
	 */
	public function getAll()
	{
		$subdivision = $this->administrativeArea->getSubdivision();
		$list = new LocalityCollection();
		$children = $subdivision->getChildren();
		/** @var Subdivision $child */
		foreach ($children as $child) {
			$locality = new static($this->administrativeArea);
			$locality->setName($child->getName());
			$locality->setLocale($child->getLocale());
			$list->insert($locality);
		}

		return $list;
	}

	/**
	 * Get a locality by name
	 *
	 * @param $name
	 * @return Locality
	 */
	public function getByName($name)
	{
		$all = $this->getAll();
		/** @var Locality $locality */
		foreach ($all as $locality) {
			if (strtolower($locality->getName()) == strtolower($name)) {
				return $locality;
			}
		}
	}

	/**
	 * Get the locality name
	 *
	 * @return string
	 */
	public function getName()
	{
		return $this->name;
	}

	/**
	 * Set the locality name
	 *
	 * @param string $name
	 */
	public function setName($name)
	{
		$this->name = $name;
	}

	/**
	 * Get the locality locale
	 *
	 * @return string
	 */
	public function getLocale()
	{
		return $this->locale;
	}

	/**
	 * Set the locality locale
{'fraction_non_alphanumeric': 0.14847417840375587, 'fraction_numerical': 0.0, 'mean_word_length': 3.393041237113402, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 37, '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': '182851', 'n_tokens_mistral': 1224, 'n_tokens_neox': 1065, 'n_words': 253}