<commit_before><?php
/**
 * @package vsc_domain
 * @subpackage models
 * @author <NAME> <<EMAIL>>
 * @date 09.11.19
 */
abstract class vscModelA extends vscNull implements vscModelI {
	private $sOffset;

	// ArrayAccess interface
	public function offsetSet($offset, $value) {
		$this->__set($offset, $value);
	}
	public function offsetExists($offset) {
		return isset($this->$offset);
	}
	public function offsetUnset($offset) {
		if (!$oProperty->isPrivate()) {
			unset($this->$sIncName);
		}
	}

	public function offsetGet($offset) {
		return $this->__get($offset);
	}

	// Iterator interface
	public function  current  () {
		return $this->offsetGet($this->sOffset);
	}

	public function key () {
		return $this->sOffset;
	}

	public function next () {
		$aProperties = $this->getProperties();
		ksort($aProperties);
		$aKeys = array_keys ($aProperties);

		if (in_array($this->sOffset, $aKeys));
			$iNext = key($aKeys)+1;

		return $iNext;
	}
	public function rewind () {
		$aProperties = $this->getProperties();
		ksort($aProperties);
		$aKeys = array_keys ($aProperties);

		if (in_array($this->sOffset, $aKeys));
			$iPrev = key($aKeys)-1;

		return $iPrev;
	}
	public function valid () {
		return (in_array($this->getProperties(), $this->sOffset));
	}

	// Countable interface
	public function count () {
		return count ($this->toArray());
	}

	public function __get ($sIncName) {
		try {
			$oProperty = new ReflectionProperty($this, $sIncName);
		} catch (ReflectionException $e) {
			//
		}
		if (!$oProperty->isPrivate()) {
			// setting $sIncName to be the current element
			$this->sOffset = $sIncName;
			return $this->$sIncName;
		}
	}

	public function __set($sIncName, $value) {
		$oProperty = new ReflectionProperty($this, $sIncName);
		$sSetterName = 'set'.ucfirst($sIncName);
		$oSetter = new ReflectionMethod($this, $sSetterName);
//		d ($oSetter);
		if (!$oProperty->isPrivate()) {
			// setting $sIncName to be the current element
			$this->sOffset = $sIncName;
			$sSetterName = 'set'.ucfirst($sIncName);
			$oSetter = new ReflectionMethod($this, $sSetterName);
//			d ($oSetter);

			$this->$sSetterName($value);
		}
	}

	private function getProperties () {
		$aRet = array();
		$t = new ReflectionObject($this);
		$aProperties = $t->getProperties();

		/* @var $oProperty ReflectionProperty */
		foreach ($aProperties as $oProperty) {
			if (!$oProperty->isPrivate()) {
				$aRet[$oProperty->getName()] = $this->__get($oProperty->getName());
			}
		}
		return $aRet;
	}

	public function toArray () {
		return $this->getProperties();
	}
}<commit_msg>* some changes to make the abstract model behave like a proper array - still not fully functional<commit_after><?php
/**
 * @package vsc_domain
 * @subpackage models
 * @author <NAME> <<EMAIL>>
 * @date 09.11.19
 */
abstract class vscModelA extends vscNull implements vscModelI {
	private $sOffset;

	// ArrayAccess interface
	public function offsetSet($offset, $value) {
		$this->__set($offset, $value);
	}
	public function offsetExists($offset) {
		return isset($this->$offset);
	}
	public function offsetUnset($offset) {
		if (!$oProperty->isPrivate()) {
			unset ($this->$offset);
		}
	}

	public function offsetGet($offset) {
		return $this->__get($offset);
	}

	// Iterator interface
	public function current  () {
		return $this->offsetGet($this->sOffset);
	}

	public function key () {
		return $this->sOffset;
	}

	public function next () {
		$aProperties = $this->getProperties();
		$aKeys = array_keys ($aProperties);

		$iCurrent = array_search($this->sOffset, $aKeys);

		if ($iCurrent+1 < $this->count()) {
			$this->sOffset = $aKeys[$iCurrent+1];
		} else {
			$this->sOffset = null;
		}
	}

	public function rewind () {
		$aProperties = $this->getProperties();
		$aKeys = array_keys ($aProperties);

		$this->sOffset = $aKeys[0];
	}

	public function valid () {
		$oRObject = new ReflectionObject ($this);
		return ($oRObject->hasProperty($this->sOffset) && $oRObject->getProperty($this->sOffset)->isPublic());
	}

	// Countable interface
	public function count () {
		return count ($this->getProperties());
	}

	public function __get ($sIncName) {
		try {
			$oProperty = new ReflectionProperty($this, $sIncName);
			if (!$oProperty->isPublic()) {
				// try for a getter method
				$sGetterName = 'get'.ucfirst($sIncName);
				$oGetter = new ReflectionMethod($this, $sGetterName);

				$this->sOffset = $sIncName; // ?? I wonder if setting the offset to the current read position is the right way
				return $oGetter->invoke($this, $sIncName);
			} else {
				$this->sOffset = $sIncName; // ?? I wonder if setting the offset to the current read position is the right way
				return $oProperty->getValue($this);
			}
		} catch (ReflectionException $e) {
//			$this->sOffset = $sIncName;
//			return $this->$sIncName;
		}
//		d ($sIncName, $oProperty, $oProperty->getValue($this));
		parent::__get ($sIncName);
	}

	public function __set($sIncName, $value) {
		if (is_null($sIncName)) {
			throw ReflectionError ('Can\'t set a value to a null property on the current object ['. get_class ($this).']');
		}
		try {
			$oProperty = new ReflectionProperty($this, $sIncName);
			if (!$oProperty->isPublic()) {
				// trying for a setter
				$sSetterName = 'set'.ucfirst($sIncName);
				$oSetter = new ReflectionMethod($this, $sSetterName);

				$oSetter->invoke($this, $value);
			} else {
				$oProperty->setValue($this, $value);
			}

			$this->sOffset = $sIncName;
			return;
		} catch (ReflectionException $e) {
//			$this->sOffset = $sIncName;
//			$this->$sIncName = $value;
		}

		parent::__set ($sIncName, $value);
	}

	public function __construct () {
		$this->rewind();
	}

	private function getProperties () {
		$aRet = array();
		$t = new ReflectionObject($this);
		$aProperties = $t->getProperties();

		/* @var $oProperty ReflectionProperty */
		foreach ($aProperties as $oProperty) {
			if ($oProperty->isPublic()) {
				$aRet[$oProperty->getName()] = $this->__get($oProperty->getName());
			}
		}
		return $aRet;
	}

	public function toArray () {
		return $this->getProperties();
	}
}
{'fraction_non_alphanumeric': 0.16880131362889983, 'fraction_numerical': 0.0027914614121510675, 'mean_word_length': 3.931983805668016, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 78, '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': '7042752', 'n_tokens_mistral': 2311, 'n_tokens_neox': 2056, 'n_words': 473}