<commit_before><?php
	namespace Bolt;

	use \Bolt\Exceptions\Framework as Exception;

	abstract class Base
	{
		public function __construct($data = null)
		{
			if ($data !== null)
			{
				$this->populate($data);
			}
		}

		protected function populate($data)
		{
			$properties = $this->getProperties();

			if (count($properties) > 0)
			{
				foreach ($properties as $property)
				{
					if (is_array($data))
					{
						$value = isset($data[$property->name]) ? $data[$property->name] : null;
					}
					else
					{
						$value = isset($data->{$property->name}) ? $data->{$property->name} : null;
					}

					if ($value !== null)
					{
						$this->{$property->name}($value);
					}
				}
			}

			return true;
		}

		protected function getProperties()
		{
			$reflection = new \ReflectionClass($this->className());
			return $reflection->getProperties(\ReflectionProperty::IS_PUBLIC);
		}

		public function className($full = true)
		{
			$className = get_class($this);

			if ($full === false)
			{
				$namespace = explode("\\", $className);
				$className = $namespace[count($namespace) - 1];
			}

			return $className;
		}

		protected function calculateNamespace($object)
		{
			$namespace = array(
				__NAMESPACE__,<commit_msg>Update populate method to recurse through nesting<commit_after><?php
	namespace Bolt;

	use \Bolt\Exceptions\Framework as Exception;

	abstract class Base
	{
		public function __construct($data = null)
		{
			if ($data !== null)
			{
				$this->populate($data);
			}
		}

		protected function populate($data)
		{
			$properties = $this->getProperties();

			if (count($properties) > 0)
			{
				foreach ($properties as $property)
				{
					if (is_array($data))
					{
						$value = isset($data[$property->name]) ? $data[$property->name] : null;
					}
					else
					{
						$value = isset($data->{$property->name}) ? $data->{$property->name} : null;
					}

					if ($value !== null)
					{
						if (is_object($value))
						{
							$value = $this->{$property->name}->populate($value);
						}
						else
						{
							$this->{$property->name}($value);
						}
					}
				}
			}

			return true;
		}

		protected function getProperties()
		{
			$reflection = new \ReflectionClass($this->className());
			return $reflection->getProperties(\ReflectionProperty::IS_PUBLIC);
		}

		public function className($full = true)
		{
			$className = get_class($this);

			if ($full === false)
			{
				$namespace = explode("\\", $className);
				$className = $namespace[count($namespace) - 1];
			}

			return $className;
		}

		protected function calculateNamespace($object)
		{
			$namespace = array(
				__NAMESPACE__,
{'fraction_non_alphanumeric': 0.1642239759488914, 'fraction_numerical': 0.001503194287861706, 'mean_word_length': 2.7598870056497176, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 32, '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': '1399278', 'n_tokens_mistral': 1131, 'n_tokens_neox': 833, 'n_words': 166}