TemporaryContainer::destroy()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
rs 9.4286
cc 2
eloc 3
nc 2
nop 0
1
<?php
2
3
/**
4
 * This file is part of peridot-temporary-plugin.
5
 *
6
 * (c) Noritaka Horio <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace holyshared\peridot\temporary;
13
14
use \SplObjectStorage;
15
use \Countable;
16
17
18
class TemporaryContainer implements Countable
19
{
20
21
    private $container;
22
23
    public function __construct()
24
    {
25
        $this->container = new SplObjectStorage();
26
    }
27
28
    public function add(FileSystemNode $node)
29
    {
30
        $this->container->attach($node);
31
    }
32
33
    public function count()
34
    {
35
        return $this->container->count();
36
    }
37
38
    public function isEmpty()
39
    {
40
        return $this->count() <= 0;
41
    }
42
43
    public function destroy()
44
    {
45
        foreach ($this->container as $node) {
46
            $node->remove();
47
        }
48
    }
49
50
}
51