Completed
Push — master ( d6f0bd...41a21b )
by Ivannis Suárez
05:43
created

DataSourceSet.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/**
4
 * This file is part of the Cubiche package.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
namespace Cubiche\Core\Collections;
12
13
use Cubiche\Core\Collections\ArrayCollection\ArraySet;
14
use Cubiche\Core\Collections\LazyCollection\LazySet;
15
use Cubiche\Core\Specification\SpecificationInterface;
16
17
/**
18
 * Data Source Set.
19
 *
20
 * @author Karel Osorio Ramírez <[email protected]>
21
 * @author Ivannis Suárez Jerez <[email protected]>
22
 */
23 View Code Duplication
class DataSourceSet extends LazySet
0 ignored issues
show
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24
{
25
    use DataSourceCollectionTrait;
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function findOne(SpecificationInterface $criteria)
31
    {
32
        if ($this->isInitialized()) {
33
            return parent::findOne($criteria);
34
        }
35
36
        return $this->dataSource->filteredDataSource($criteria)->findOne();
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    protected function initialize()
43
    {
44
        $this->collection = new ArraySet();
45
46
        $this->collection->addAll($this->dataSource->getIterator());
47
    }
48
}
49