for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Webfactor\Laravel\Generators\Contracts;
use Webfactor\Laravel\Generators\Traits\CrudColumn;
use Webfactor\Laravel\Generators\Traits\CrudField;
use Webfactor\Laravel\Generators\Traits\ValidationRule;
abstract class MigrationFieldAbstract implements MigrationFieldTypeInterface
{
use CrudColumn, CrudField, ValidationRule;
private $name;
private $nullable;
private $unique;
public function __construct(string $name, array $options = [])
$this->name = $name;
foreach ($options as $option) {
$this->parseOptions($option);
}
private function parseOptions(string $param)
if ($param == 'nullable') {
return $this->nullable = true;
if ($param == 'unique') {
return $this->unique = true;
if (starts_with($param, 'default(')) {
preg_match('/\((.*)\)/', $param, $match);
return $this->default = $match[1];
default
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;
/**
* @return string
*/
public function getName()
return $this->name;
* @return bool
public function isNullable()
return $this->nullable;
public function isUnique(): bool
return $this->unique;
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: