src/AbstractEntity.php
protected function createAccessor(
        $accessor,
        string $name,
        $value,
        array $context = []
    ): AccessorInterface {
        if (!is_string($accessor) || !class_exists($accessor)) {
            throw new EntityException(
                "Unable to create accessor for field `{$name}` in " . static::class
            );
        }

        //Field as a context
        return new $accessor($value, $context + ['field' => $name, 'entity' => $this]);
    }
protected function createAccessor(
        $accessor,
        string $name,
        $value,
        array $context = []
    ): AccessorInterface {
        if (!is_string($accessor) || !class_exists($accessor)) {
            throw new EntityException(
                "Unable to create accessor for field `{$name}` in " . static::class
            );
        }

        //Field as a context
        return new $accessor($value, $context + ['field' => $name, 'entity' => $this]);
    }
protected function createAccessor ( $ accessor , string $ name , $ value , array $ context = [ ] ) : AccessorInterface { if ( ! is_string ( $ accessor ) || ! class_exists ( $ accessor ) ) { throw new EntityException ( "Unable to create accessor for field `{$name}` in " . static :: class ) ; } //Field as a context return new $ accessor ( $ value , $ context + [ 'field' => $ name , 'entity' => $ this ] ) ; }
Create instance of field accessor.

@param mixed|string $accessor Might be entity implementation specific.
@param string       $name
@param mixed        $value
@param array        $context  Custom accessor context.

@return AccessorInterface|null

@throws \Spiral\Models\Exception\AccessException
@throws EntityException
Create instance of field accessor .