OptionableView::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
/*
4
 * This file is part of the Pagerfanta package.
5
 *
6
 * (c) Pablo Díez <[email protected]>
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 Pagerfanta\View;
13
14
use Pagerfanta\PagerfantaInterface;
15
16
/**
17
 * OptionableView.
18
 *
19
 * This view renders another view with a default options to reuse them in a project.
20
 *
21
 * @author Pablo Díez <[email protected]>
22
 */
23
class OptionableView implements ViewInterface
24
{
25
    private $view;
26
    private $defaultOptions;
27
28
    /**
29
     * Constructor.
30
     *
31
     * @param ViewInterface $view           A view.
32
     * @param array         $defaultOptions An array of default options.
33
     */
34 2
    public function __construct(ViewInterface $view, array $defaultOptions)
35
    {
36 2
        $this->view = $view;
37 2
        $this->defaultOptions = $defaultOptions;
38 2
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43 2
    public function render(PagerfantaInterface $pagerfanta, $routeGenerator, array $options = array())
44
    {
45 2
        return $this->view->render($pagerfanta, $routeGenerator, array_merge($this->defaultOptions, $options));
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function getName()
52
    {
53
        return 'optionable';
54
    }
55
}
56