for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace SmartWeb\ModuleTesting\Support\Concerns;
use Illuminate\Support\Str;
/**
* Trait MutatesAttributes
*
* @package SmartWeb\ModuleTesting\Support\Concerns
*/
trait MutatesAttributes
{
* @var array
protected static $mutators = [];
* @param string $attribute
* @return bool
protected function hasGetMutator(string $attribute) : bool
return method_exists($this, $this->attributeGetMutator($attribute));
}
* @return mixed
protected function getMutatedAttribute(string $attribute)
return $this->{$this->attributeGetMutator($attribute)}($attribute);
* @return string
private function attributeGetMutator(string $attribute) : string
return static::$mutators['get'][static::class][$attribute] = static::$mutators['get'][static::class][$attribute]
?? $this->resolveGetMutator($attribute);
private function resolveGetMutator(string $attribute) : string
return 'get' . Str::studly($attribute) . 'Attribute';