PriceList   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A prepareList() 0 11 2
A convertParameters() 0 14 3
1
<?php
2
3
/**
4
 * @author Rafał Muszyński <[email protected]>
5
 * @copyright 2015 Sourcefabric z.ú.
6
 * @license http://www.gnu.org/licenses/gpl-3.0.txt
7
 */
8
namespace Newscoop\PaywallBundle\TemplateList;
9
10
use Newscoop\TemplateList\BaseList;
11
use Newscoop\PaywallBundle\Meta\MetaMainSubscription;
12
13
/**
14
 * Price List.
15
 */
16
class PriceList extends BaseList
17
{
18
    protected function prepareList($criteria, $parameters)
19
    {
20
        $service = \Zend_Registry::get('container')->get('paywall.subscription.service');
21
        $list = $service->getSubscriptionsByCriteria($criteria);
22
        $list->items = $list->items->getArrayResult();
23
        foreach ($list->items as $key => $value) {
24
            $list->items[$key] = new MetaMainSubscription($value);
25
        }
26
27
        return $list;
28
    }
29
30
    protected function convertParameters($firstResult, $parameters)
31
    {
32
        $this->criteria->orderBy = array();
33
        // run default simple parameters converting
34
        parent::convertParameters($firstResult, $parameters);
35
36
        if (array_key_exists('locale', $parameters)) {
37
            $this->criteria->locale = $parameters['locale'];
38
        }
39
40
        if (array_key_exists('type', $parameters)) {
41
            $this->criteria->type = $parameters['type'];
42
        }
43
    }
44
}
45