Get primary property reflection

@return Reflection\Property

@throws \Exception
485587
public function getPrimaryProperty()
    {
        foreach ($this->properties as $property) {

            if ($property->hasOption(Entity\Reflection\Property\Option\Primary::KEY)) {
                return $property;
            }
        }
        throw new \Exception(
            "Primary property not defined in " . $this->className . "!"
        );
    }
1287443
protected function _getReflection()
    {
        if (is_null($this->_reflection)) {
            $this->_reflection = new \ReflectionClass($this->_class);
        }
        return $this->_reflection;
    }
68656
private function getReflectionProperty($object, $property)
    {
        if (isset($this->properties[$key = $this->getCacheKey($object, $property)])) {
            return $this->properties[$key];
        }

        $reflection = new \ReflectionProperty($object, $property);
        $reflection->setAccessible(true);

        return $this->properties[$key] = $reflection;
    }
474023
private function getReflectionClass(): \ReflectionClass
    {
        if (null === $this->reflectionClass) {
            $this->reflectionClass = new \ReflectionClass(\get_class($this));
        }

        return $this->reflectionClass;
    }
226095
public static function getFacadeRoot() {
        $accessor = static::getFacadeAccessor();
        $instance = Application::getInstance()->make($accessor);
        if ($instance == null) {
            throw new Exception('Facade get null for: '.$accessor);
        }
        return $instance;
    }
1284628
public function getReflection(): ClassReflection
    {
        if (null === $this->reflection) {
            $this->reflection = new ClassReflection($this->documentClass);
        }

        return $this->reflection;
    }
820116
public function getPrimaryKey(){
		$table = $this->getTable();
		if(!$table)
			return null;
		$key = null;
		$cached = $this->connection->getCache()->fetch($table . '_primaryKey');

		if($cached === null){
			try{
				$key = $this->connection->getDriver()
					->getPrimaryKey($table, isset($this->resultSet) ? $this->resultSet : null);
			} catch(NeevoException $e){
				return null;
			}
			$this->connection->getCache()->store($table . '_primaryKey', $key);
			return $key === '' ? null : $key;
		}
		return $cached === '' ? null : $cached;
	}
746075
public function getPrimaryKey()
    {
        $columns = $this->getColumns();

        if (!isset($columns)) {
            throw new DatabaseException('Column schema not found!');
        }

        if (count($columns) > 0) {
            $primaryKey = null;
            foreach ($columns as $key => $value) {
                if ($value['COLUMN_KEY'] == 'PRI' || $value['EXTRA'] == 'auto_increment') {
                    $primaryKey = $value['COLUMN_NAME'];
                    break;
                }
            }
        }

        return $primaryKey;
    }
695589
public function getDefault() {
    	if ($this->isPublic() && !$this->isStatic() && $this->refClass->isAbstract() == false) {	    		 
	  		$className = $this->refClass->getName();
	  		// TODO: find a way to get default value for abstract properties.
	  		// TODO: optimize this: we should not have to create one new instance for every property....
	  		/*$instance = new $className();
			$property = $this->getName();
	    	return $instance->$property;*/
	  		
	  		// In some cases, the call to getDefaultProperties can log NOTICES
	  		// in particular if an undefined constant is used as default value.
	  		ob_start();
	  		$defaultProperties = $this->refClass->getDefaultProperties();
	  		$possibleError = ob_get_clean();
			if ($possibleError) {
				throw new \Exception($possibleError);	
			}
	  		return $defaultProperties[$this->getName()];
    	} else {
    		return null;
    	}
    }
841282
private function get($operand)
    {
        $reflector = $this->getReflector();

        if (!$reflector->hasProperty($operand)) {
            throw new RuntimeException('Trying to access undefined property from reflection context: ' . $operand);
        }

        $reflectionProperty = $reflector->getProperty($operand);
        if ($reflectionProperty->isPrivate()) {
            throw new RuntimeException(
                'Private properties are not allowed to be set from reflection context.' . $operand
            );
        }

        $reflectionProperty->setAccessible(true);

        return $reflectionProperty->getValue($this);
    }
745904
private function accessProperty(ReflectionClass $reflection, $property)
    {
        $propertyReflection = $reflection->getProperty($property);
        $propertyReflection->setAccessible(true);

        return $propertyReflection;
    }
212171
public function getPrimaryKey()
    {
        if (is_null($this->_primaryKey)) {
            $this->_primaryKey = $this->getDescriptor()
                ->getEntity()->getPrimaryKey();
        }
        return $this->_primaryKey;
    }
1145438
public function setPrimary($primaryName) {
		if (is_array($primaryName)) {
			$idProperty = self::COMPOSITE_ID_PROPERTY . $this->_collectionId;
			
			foreach ($this->_data as &$dataPart) {
				$dataHashParts = [];
				
				foreach ($primaryName as $keyPart) {
					if (! isset($dataPart[$keyPart])) {
						throw new Exception('Undefined property can\'t been used as a part of a composite primary');
					}
					
					$dataHashParts[] = $dataPart[$keyPart];
				}
				
				$dataPart[$idProperty] = $this->arrayHashFunction($dataHashParts);
			}
			unset($dataPart);
			
			$this->_primaryDefinition = $primaryName;
			
			$primaryName = $idProperty;
		} else {
			$this->_primaryDefinition = $primaryName;
		}
		
		$tempData = $this->_data;
		$this->_data = [];
		
		foreach ($tempData as &$item) {
			if (! isset($item[$primaryName])) {
				throw new Exception('Undefined property can\'t been used as a primary');
			}
			
			$this->_data[$item[$primaryName]] = &$item;
		}
		unset($item, $tempData);
		
		if (! empty($this->_models)) {
			$tempData = $this->_models;
			$this->_models = [];
			
			foreach ($tempData as $item) {
				$this->_models[$item->$primaryName] = $item;
			}
			
			unset($tempData);
		}
		
		$this->_pointer = 0;
		$this->_map     = array_keys($this->_data);
		$this->_primary = $primaryName;
		
		return $this;
	}
322668
public function getClass()
    {
        try {
            $class = parent::getClass();
        } catch (\Exception $e) {
            return null;
        }
        return is_object($class) ? new ClassReflection($class->getName()) : null;
    }
1212307
public function getIdentity() {
        if ($this->identity === null) {
            foreach ($this->mapping['properties'] as $name => $property) {
                if (isset($property['primary']) && $property['primary']===true) {
                    return $this->identity = new PropertyMapping($this, $property);
                }
            }
            throw new RuntimeException('Invalid mapping for entity "'.$this->getClassName().'" (missing primary key mapping)');
        }
        return $this->identity;
    }
1096662
public function getPropertyAccessor()
    {
        return new PropertyAccessor($this->magicCall, $this->throwExceptionOnInvalidIndex, $this->cacheItemPool, $this->throwExceptionOnInvalidPropertyPath);
    }
327112
public PropertyInterface getProperty() {
		if (property == null) {
			property = Properties.getPropertyByPath(classHolder.getClazz(), path);
		}
		return property;
	}