source/Spiral/ORM/Entities/Relations/Traits/MatchTrait.php
protected function match(RecordInterface $record, $query): bool
    {
        if ($record === $query) {
            //Strict search
            return true;
        }

        //Primary key comparision
        if (is_scalar($query) && $record->primaryKey() == $query) {
            return true;
        }

        //Record based comparision
        if ($query instanceof RecordInterface) {
            //Matched by PK (assuming both same class)
            if (!empty($query->primaryKey()) && $query->primaryKey() == $record->primaryKey()) {
                return true;
            }

            //Matched by content (this is a bit tricky!)
            if ($record->packValue() == $query->packValue()) {
                return true;
            }

            return false;
        }

        //Field intersection
        if (is_array($query) && array_intersect_assoc($record->packValue(), $query) == $query) {
            return true;
        }

        return false;
    }
protected function match(RecordInterface $record, $query): bool
    {
        if ($record === $query) {
            //Strict search
            return true;
        }

        //Primary key comparision
        if (is_scalar($query) && $record->primaryKey() == $query) {
            return true;
        }

        //Record based comparision
        if ($query instanceof RecordInterface) {
            //Matched by PK (assuming both same class)
            if (!empty($query->primaryKey()) && $query->primaryKey() == $record->primaryKey()) {
                return true;
            }

            //Matched by content (this is a bit tricky!)
            if ($record->packValue() == $query->packValue()) {
                return true;
            }

            return false;
        }

        //Field intersection
        if (is_array($query) && array_intersect_assoc($record->packValue(), $query) == $query) {
            return true;
        }

        return false;
    }
protected function match ( RecordInterface $ record , $ query ) : bool { if ( $ record === $ query ) { //Strict search return true ; } //Primary key comparision if ( is_scalar ( $ query ) && $ record -> primaryKey ( ) == $ query ) { return true ; } //Record based comparision if ( $ query instanceof RecordInterface ) { //Matched by PK (assuming both same class) if ( ! empty ( $ query -> primaryKey ( ) ) && $ query -> primaryKey ( ) == $ record -> primaryKey ( ) ) { return true ; } //Matched by content (this is a bit tricky!) if ( $ record -> packValue ( ) == $ query -> packValue ( ) ) { return true ; } return false ; } //Field intersection if ( is_array ( $ query ) && array_intersect_assoc ( $ record -> packValue ( ) , $ query ) == $ query ) { return true ; } return false ; }
Match entity by field intersection, instance values or primary key.

@param RecordInterface             $record
@param RecordInterface|array|mixed $query

@return bool
Match entity by field intersection instance values or primary key .