for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Sco\Admin\Fields;
use JsonSerializable;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Jsonable;
use Sco\Admin\Contracts\Field as FieldContract;
abstract class Field implements FieldContract, Arrayable, Jsonable, JsonSerializable
{
protected $type;
protected $name;
protected $title;
public function __construct($name, $title)
$this->name = $name;
$this->title = $title;
}
public function isRelationship()
return !empty($this->relationship);
relationship
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;
public function toArray()
return [
'key' => $this->name,
'title' => $this->title,
'type' => $this->type,
];
public function jsonSerialize()
return $this->toArray();
public function toJson($options = 0)
return json_encode($this->jsonSerialize(), $options);
public function __toString()
return $this->toJson();
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: