Completed
Push — master ( 4e4cd8...063296 )
by Maksim
16s
created

Propel1PagerProvider::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
/*
4
 * This file is part of the FOSElasticaBundle package.
5
 *
6
 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
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 FOS\ElasticaBundle\Propel;
13
14
use FOS\ElasticaBundle\Provider\PagerfantaPager;
15
use FOS\ElasticaBundle\Provider\PagerProviderInterface;
16
use Pagerfanta\Adapter\PropelAdapter;
17
use Pagerfanta\Pagerfanta;
18
19
final class Propel1PagerProvider implements PagerProviderInterface
20
{
21
    /**
22
     * @var string
23
     */
24
    private $objectClass;
25
    
26
    /**
27
     * @var array
28
     */
29
    private $baseOptions;
30
31
    /**
32
     * @param string $objectClass
33
     * @param array $baseOptions
34
     */
35 2
    public function __construct($objectClass, array $baseOptions)
36
    {
37 2
        $this->objectClass = $objectClass;
38 2
        $this->baseOptions = $baseOptions;
39 2
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44 1
    public function provide(array $options = array())
45
    {
46 1
        $options = array_replace($this->baseOptions, $options);
0 ignored issues
show
Unused Code introduced by
$options is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
47
        
48 1
        $queryClass = $this->objectClass.'Query';
49
50 1
        $adapter = new PropelAdapter($queryClass::create());
51
52 1
        return new PagerfantaPager(new Pagerfanta($adapter));
53
    }
54
}
55