<commit_before><?php

namespace WernerDweight\Dobee\Traits;

trait ModelHelper {

	protected function getPrimaryKeyForEntity($entity){
		if(isset($this->model[$entity]['extends'])){
			return $this->getPrimaryKeyForEntity($this->model[$entity]['extends']);
		}
		return $this->model[$entity]['primary'];
	}

	protected function hasProperty($entity,$property){
		if(isset($this->model[$entity]['properties'][$property])){
			return true;
		}
		else if(isset($this->model[$entity]['extends'])){
			return $this->hasProperty($this->model[$entity]['extends'],$property);
		}
		else{
			return false;
		}
	}

	protected function getEntityName($entity){
		$class = get_class($entity);
		
		if(preg_match('/\\\/',$class)){
			$class = preg_replace('/^.*\\\([a-zA-Z0-9]+)$/','$1',$class);
		}

		return lcfirst($class);
	}

	protected function getEntityProperties($entity){
		$properties = array();

		if(isset($this->model[$entity]['properties'])){
			foreach ($this->model[$entity]['properties'] as $property => $options) {
				$properties[$property] = $property;
			}
		}
		if(isset($this->model[$entity]['extends'])){
			$properties = array_merge($properties,$this->getEntityProperties($this->model[$entity]['extends']));
		}

		return $properties;
	}

	protected function getEntityRelations($entity){
		$relations = array();

		if(isset($this->model[$entity]['relations'])){
			foreach ($this->model[$entity]['relations'] as $relatedEntity => $cardinality) {
				if(in_array($cardinality, array('<<ONE_TO_ONE','MANY_TO_ONE','<<MANY_TO_MANY'))){
					$relations[$relatedEntity] = $cardinality;
				}
			}
		}
		if(isset($this->model[$entity]['extends'])){
			$relations = array_merge($relations,$this->getEntityRelations($this->model[$entity]['extends']));
		}

		return $relations;
	}<commit_msg>[FIX] update for previous fix<commit_after><?php

namespace WernerDweight\Dobee\Traits;

trait ModelHelper {

	protected function getPrimaryKeyForEntity($entity){
		if(isset($this->model[$entity]['extends'])){
			return $this->getPrimaryKeyForEntity($this->model[$entity]['extends']);
		}
		return $this->model[$entity]['primary'];
	}

	protected function hasProperty($entity,$property){
		if(isset($this->model[$entity]['properties'][$property])){
			return true;
		}
		else if(isset($this->model[$entity]['extends'])){
			return $this->hasProperty($this->model[$entity]['extends'],$property);
		}
		else{
			return false;
		}
	}

	protected function getEntityName($entity){
		$class = get_class($entity);
		
		if(preg_match('/\\\/',$class)){
			$class = preg_replace('/^.*\\\([a-zA-Z0-9]+)$/','$1',$class);
		}

		return lcfirst($class);
	}

	protected function getEntityProperties($entity){
		$properties = array();

		if(isset($this->model[$entity]['properties'])){
			foreach ($this->model[$entity]['properties'] as $property => $options) {
				$properties[$property] = $property;
			}
		}
		if(isset($this->model[$entity]['extends'])){
			$properties = array_merge($properties,$this->getEntityProperties($this->model[$entity]['extends']));
		}

		return $properties;
	}

	protected function getEntityRelations($entity){
		$relations = array();

		if(isset($this->model[$entity]['relations'])){
			foreach ($this->model[$entity]['relations'] as $relatedEntity => $cardinality) {
				if(in_array($cardinality, array('<<ONE_TO_ONE','MANY_TO_ONE','<<MANY_TO_MANY','SELF::ONE_TO_MANY','SELF::MANY_TO_ONE'))){
					$relations[$relatedEntity] = $cardinality;
				}
			}
		}
		if(isset($this->model[$entity]['extends'])){
			$relations = array_merge($relations,$this->getEntityRelations($this->model[$entity]['extends']));
		}

		return $relations;
	}
{'fraction_non_alphanumeric': 0.21471718835804504, 'fraction_numerical': 0.0016474464579901153, 'mean_word_length': 5.886578449905482, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 43, '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': '6776879', 'n_tokens_mistral': 1329, 'n_tokens_neox': 1160, 'n_words': 152}