MiniAsset\AssetCollection::remove PHP Method

remove() public method

Remove an asset from the collection
public remove ( string $name ) : void
$name string The name of the asset you want to remove
return void
    public function remove($name)
    {
        if (!isset($this->indexed[$name])) {
            return;
        }
        unset($this->indexed[$name]);
        foreach ($this->items as $i => $v) {
            if ($v === $name) {
                unset($this->items[$i]);
            }
        }
    }

Usage Example

 public function testRemove()
 {
     $collection = new AssetCollection(['libs.js', 'all.css'], $this->factory);
     $this->assertNull($collection->remove('libs.js'));
     $this->assertFalse($collection->contains('libs.js'));
     $this->assertNull($collection->get('libs.js'));
     foreach ($collection as $item) {
         $this->assertNotEquals('libs.js', $item->name());
     }
 }