Illuminate\Database\Eloquent\Model::cacheMutatedAttributes PHP Method

cacheMutatedAttributes() public static method

Extract and cache all the mutated attributes of a class.
public static cacheMutatedAttributes ( string $class ) : void
$class string
return void
    public static function cacheMutatedAttributes($class)
    {
        $mutatedAttributes = [];
        // Here we will extract all of the mutated attributes so that we can quickly
        // spin through them after we export models to their array form, which we
        // need to be fast. This'll let us know the attributes that can mutate.
        if (preg_match_all('/(?<=^|;)get([^;]+?)Attribute(;|$)/', implode(';', get_class_methods($class)), $matches)) {
            foreach ($matches[1] as $match) {
                if (static::$snakeAttributes) {
                    $match = Str::snake($match);
                }
                $mutatedAttributes[] = lcfirst($match);
            }
        }
        static::$mutatorCache[$class] = $mutatedAttributes;
    }
Model