for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Xetaravel\Models\Presenters;
trait UserPresenter
{
/**
* Get the account first name.
*
* @return string
*/
public function getFirstNameAttribute(): string
return $this->parse($this->account->first_name);
account
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
}
* Get the account last name.
public function getLastNameAttribute(): string
return $this->parse($this->account->last_name);
* Get the account full name.
public function getFullNameAttribute(): string
return $this->parse($this->account->first_name) . ' ' . $this->parse($this->account->last_name);
* Get the account facebook.
public function getFacebookAttribute(): string
return $this->parse($this->account->facebook);
* Get the account twitter.
public function getTwitterAttribute(): string
return $this->parse($this->account->twitter);
* Get the account biography.
public function getBiographyAttribute(): string
return $this->parse($this->account->biography);
* Get the account signature.
public function getSignatureAttribute(): string
return $this->parse($this->account->signature);
* Parse an attribute and return its value or empty if null.
* @param string|null $attribute The attribute to parse.
protected function parse($attribute): string
if ($attribute === null) {
return '';
return $attribute;
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: