for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Webfactor\Laravel\Generators\Contracts;
abstract class MigrationFieldAbstract implements FieldTypeInterface
{
private $name;
private $nullable = false;
private $unique = false;
private $default = null;
private $foreign = null;
public function __construct(string $name, array $options = [])
$this->name = $name;
foreach ($options as $option) {
$this->fillObject($option);
}
private function fillObject(string $param)
if ($param == 'nullable') {
return $this->nullable = true;
if ($param == 'unique') {
return $this->unique = true;
if ($param == 'foreign') {
return $this->foreign = true;
if (starts_with($param, 'default(')) {
preg_match('/\((.*)\)/', $param, $match);
return $this->default = $match[1];
/**
* @return string
*/
public function getName()
return $this->name;
public function getType()
return $this->type;
type
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 mixed
string
This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.
array
public function getDefault()
return $this->default;
* @return bool
public function isNullable()
return $this->nullable;
public function isUnique(): bool
return $this->unique;
abstract public function getRule(): string;
abstract public function getColumn(): array;
abstract public function getField(): array;
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: