scratch – Blame information for rev 115

Subversion Repositories:
Rev:
Rev Author Line No. Line
115 office 1 <?php
2  
3 /*
4 * This file is part of PHP-FFmpeg.
5 *
6 * (c) Alchemy <dev.team@alchemy.fr>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11  
12 namespace FFMpeg\Filters;
13  
14 class FiltersCollection implements \Countable, \IteratorAggregate
15 {
16 private $sorted;
17 private $filters = array();
18  
19 /**
20 * @param FilterInterface $filter
21 *
22 * @return FiltersCollection
23 */
24 public function add(FilterInterface $filter)
25 {
26 $this->filters[$filter->getPriority()][] = $filter;
27 $this->sorted = null;
28  
29 return $this;
30 }
31  
32 /**
33 * {@inheritdoc}
34 */
35 public function count()
36 {
37 if (0 === count($this->filters)) {
38 return 0;
39 }
40  
41 return count(call_user_func_array('array_merge', $this->filters));
42 }
43  
44 /**
45 * {@inheritdoc}
46 */
47 public function getIterator()
48 {
49 if (null === $this->sorted) {
50 if (0 === count($this->filters)) {
51 $this->sorted = $this->filters;
52 } else {
53 krsort($this->filters);
54 $this->sorted = call_user_func_array('array_merge', $this->filters);
55 }
56 }
57  
58 return new \ArrayIterator($this->sorted);
59 }
60 }