flagsmith-php-client icon indicating copy to clipboard operation
flagsmith-php-client copied to clipboard

Flagsmith instance clonning

Open misakstvanu opened this issue 7 months ago • 0 comments

Hi, clonning the instance with every configuration change is very expensive and not necessary in context of this library, I propose just setting the property and returning original object.

This also fixes Flagsmith.php line 183

    public function withCache(?CacheInterface $cache): self
    {
        if (is_null($cache)) {
            $this->with('cache', null); <-- result of this expression is not used anywhere (someone probably missed the clonning)
        }

        return $this->with(
            'cache',
            new Cache($cache, $this->cachePrefix, $this->timeToLive)
        );
    }

misakstvanu avatar Jul 24 '24 10:07 misakstvanu