src/Entity/Collection.php
public function getByPrimary($value)
    {
        foreach ($this->data as $entity) {

            $primaryPropertyName = $entity::getReflection()
                ->getPrimaryProperty()
                ->getName();

            $primaryValue = $entity->{$primaryPropertyName};
            if ($primaryValue === $value && $primaryValue !== null) {
                return $entity;
            }
        }
        return false;
    }
public function getByPrimary($value)
    {
        foreach ($this->data as $entity) {

            $primaryPropertyName = $entity::getReflection()
                ->getPrimaryProperty()
                ->getName();

            $primaryValue = $entity->{$primaryPropertyName};
            if ($primaryValue === $value && $primaryValue !== null) {
                return $entity;
            }
        }
        return false;
    }
public function getByPrimary ( $ value ) { foreach ( $ this -> data as $ entity ) { $ primaryPropertyName = $ entity :: getReflection ( ) -> getPrimaryProperty ( ) -> getName ( ) ; $ primaryValue = $ entity -> { $ primaryPropertyName } ; if ( $ primaryValue === $ value && $ primaryValue !== null ) { return $ entity ; } } return false ; }
Get entity by primary value

@param mixed $value

@return Entity|false
Get entity by primary value