Former\Traits\Field::automaticLabels PHP Method

automaticLabels() private method

Ponders a label and a field name, and tries to get the best out of it
private automaticLabels ( string $name, string $label ) : false | null
$name string A field name
$label string A label
return false | null A label and a field name
    private function automaticLabels($name, $label)
    {
        // Disabled automatic labels
        if (!$this->app['former']->getOption('automatic_label')) {
            $this->name = $name;
            $this->label($label);
            return false;
        }
        // Check for the two possibilities
        if ($label and is_null($name)) {
            $name = Str::slug($label);
        } elseif (is_null($label) and $name) {
            $label = preg_replace('/\\[\\]$/', '', $name);
        }
        // Save values
        $this->name = $name;
        $this->label($label);
    }