public static function keyGet( $data )
    {

        // Is a Entity object ?
        $class = get_called_class();
        if( $data instanceof $class ) {

            $keys = array();
            foreach( static::$keyProperties as $property ) {

                $value = $data->get($property);

                // resolve entities back down to their key
                if( $value instanceof Base ) {
                    $value = call_user_func(
                        array( get_class($value), 'keyGet' ),
                        $value
                    );
                }

                $keys[$property] = $value;

            }

         // is a data array
        } elseif( is_array( $data ) ) {
            $keys = array_intersect_key(
                $data,
                array_flip( static::$keyProperties )
            );
        }

        // build and return the key
        if( isset( $keys ) ) {

            $key = implode( self::KEY_SEPARATOR, $keys );
            return strlen( trim( $key, self::KEY_SEPARATOR ) ) === 0
                ? null
                : $key;

        }

        throw new BadKeyException("Cant determine a key from this");

    }
public static function keyGet( $data )
    {

        // Is a Entity object ?
        $class = get_called_class();
        if( $data instanceof $class ) {

            $keys = array();
            foreach( static::$keyProperties as $property ) {

                $value = $data->get($property);

                // resolve entities back down to their key
                if( $value instanceof Base ) {
                    $value = call_user_func(
                        array( get_class($value), 'keyGet' ),
                        $value
                    );
                }

                $keys[$property] = $value;

            }

         // is a data array
        } elseif( is_array( $data ) ) {
            $keys = array_intersect_key(
                $data,
                array_flip( static::$keyProperties )
            );
        }

        // build and return the key
        if( isset( $keys ) ) {

            $key = implode( self::KEY_SEPARATOR, $keys );
            return strlen( trim( $key, self::KEY_SEPARATOR ) ) === 0
                ? null
                : $key;

        }

        throw new BadKeyException("Cant determine a key from this");

    }
public static function keyGet ( $ data ) { // Is a Entity object ? $ class = get_called_class ( ) ; if ( $ data instanceof $ class ) { $ keys = array ( ) ; foreach ( static :: $ keyProperties as $ property ) { $ value = $ data -> get ( $ property ) ; // resolve entities back down to their key if ( $ value instanceof Base ) { $ value = call_user_func ( array ( get_class ( $ value ) , 'keyGet' ) , $ value ) ; } $ keys [ $ property ] = $ value ; } // is a data array } elseif ( is_array ( $ data ) ) { $ keys = array_intersect_key ( $ data , array_flip ( static :: $ keyProperties ) ) ; } // build and return the key if ( isset ( $ keys ) ) { $ key = implode ( self :: KEY_SEPARATOR , $ keys ) ; return strlen ( trim ( $ key , self :: KEY_SEPARATOR ) ) === 0 ? null : $ key ; } throw new BadKeyException ( "Cant determine a key from this" ) ; }
Key entity `key`
@param array|Entity\Base $data
@return array
Key entity key