ScriptFUSION\Porter\Options\EncapsulatedOptions::copy PHP Méthode

copy() final public méthode

Creates a copy of the encapsulated options.
final public copy ( ) : array
Résultat array Options.
    public final function copy()
    {
        return $this->options + $this->defaults;
    }

Usage Example

 public function fetch($source, EncapsulatedOptions $options = null)
 {
     $optionsCopy = $options ? $options->copy() : [];
     if ($this->isCacheEnabled()) {
         ksort($optionsCopy);
         $hash = $this->hash([$source, $optionsCopy]);
         if ($this->cache->hasItem($hash)) {
             return $this->cache->getItem($hash)->get();
         }
     }
     $data = $this->fetchFreshData($source, $options);
     isset($hash) && $this->cache->save($this->cache->getItem($hash)->set($data));
     return $data;
 }