KnpLabs / DoctrineBehaviors

Doctrine2 behavior traits that help handling Blameable, Loggable, Sluggable, SoftDeletable, Uuidable, Timestampable, Translatable, Tree behavior
http://knplabs.com
MIT License
911 stars 286 forks source link

Make setDefaultLocale() fluent #740

Open tacman opened 9 months ago

tacman commented 9 months ago
    public function setDefaultLocale(string $locale): void
    {
        $this->defaultLocale = $locale;
    }

    // proposal:
    public function setDefaultLocale(string $locale): self
    {
        $this->defaultLocale = $locale;
        return $this;
    }

If this method were fluent, we could do the following.

// currently
$project->setDefaultLocale('es');
$project->setTitle('dos libros');
// easier
$project
   ->setDefaultLocale('es')
   ->setTitle('dos libros');