83% of 127OPs |
93% of 15Lines |
83% of 12Branches |
86% of 7Paths |
Method | OPs | OPs % | Lines | Line % | Branches | Branches % | Paths | Path % |
---|---|---|---|---|---|---|---|---|
mageekguy\atoum\iterators\filters\recursives\extension::__construct() | 41 | 100% | 7 | 100% | 5 | 80% | 2 | 100% |
mageekguy\atoum\iterators\filters\recursives\extension::setAcceptedExtensions() | 17 | 100% | 3 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\iterators\filters\recursives\extension::getAcceptedExtensions() | 6 | 100% | 1 | 100% | 1 | 100% | 1 | 100% |
mageekguy\atoum\iterators\filters\recursives\extension::accept() | 42 | 100% | 3 | 100% | 4 | 100% | 2 | 100% |
mageekguy\atoum\iterators\filters\recursives\extension::getChildren() | 21 | 0% | 1 | 0% | 1 | 0% | 1 | 0% |
# | |
---|---|
1 |
<?php |
2 |
|
3 |
namespace mageekguy\atoum\iterators\filters\recursives; |
4 |
|
5 |
use |
6 |
mageekguy\atoum |
7 |
; |
8 |
|
9 |
class extension extends \recursiveFilterIterator |
10 |
{ |
11 |
protected $acceptedExtensions = array(); |
12 |
|
13 |
public function __construct($mixed, array $acceptedExtensions = array(), \closure $iteratorFactory = null)100% |
14 |
{ |
15 |
if ($mixed instanceof \recursiveIterator) |
16 |
{ |
17 |
parent::__construct($mixed); |
18 |
} |
19 |
else |
20 |
{ |
21 |
parent::__construct(call_user_func($iteratorFactory ?: function($path) { return new \recursiveDirectoryIterator($path); }, (string) $mixed)); |
22 |
} |
23 |
|
24 |
$this->setAcceptedExtensions($acceptedExtensions); |
25 |
} |
26 |
|
27 |
public function setAcceptedExtensions(array $extensions)100% |
28 |
{ |
29 |
array_walk($extensions, function(& $extension) { $extension = trim($extension, '.'); }); |
30 |
|
31 |
$this->acceptedExtensions = $extensions; |
32 |
|
33 |
return $this; |
34 |
} |
35 |
|
36 |
public function getAcceptedExtensions()100% |
37 |
{ |
38 |
return $this->acceptedExtensions; |
39 |
} |
40 |
|
41 |
public function accept()100% |
42 |
{ |
43 |
$path = basename((string) $this->getInnerIterator()->current()); |
44 |
|
45 |
$extension = pathinfo($path, PATHINFO_EXTENSION); |
46 |
|
47 |
return ($extension == '' || in_array($extension, $this->acceptedExtensions) === true); |
48 |
} |
49 |
|
50 |
public function getChildren()0% |
51 |
{ |
52 |
return new self($this->getInnerIterator()->getChildren(), $this->acceptedExtensions); |
53 |
} |
54 |
} |