Completed
Push — 3.1 ( 7e9d2a...4fdd2b )
by Piotr
13:37 queued 13:35
created

NewsDataSourceBuilder   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A buildNewsDataSource() 0 41 1
1
<?php
2
3
/**
4
 * (c) FSi sp. z o.o. <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace FSi\FixturesBundle\DataSource;
13
14
use FSi\Component\DataSource\DataSourceInterface;
15
16
class NewsDataSourceBuilder
17
{
18
    public static function buildNewsDataSource(DataSourceInterface $datasource): DataSourceInterface
19
    {
20
        $datasource->addField('title', 'text', 'like', [
21
            'sortable' => false,
22
            'form_options' => [
23
                'label' => 'admin.news.list.title',
24
            ]
25
        ]);
26
27
        $datasource->addField('created_at', 'date', 'between', [
28
            'field' => 'createdAt',
29
            'sortable' => true,
30
            'form_from_options' => [
31
                'widget' => 'single_text',
32
                'label' => 'admin.news.list.created_at_from',
33
            ],
34
            'form_to_options' => [
35
                'widget' => 'single_text',
36
                'label' => 'admin.news.list.created_at_to',
37
            ]
38
        ]);
39
40
        $datasource->addField('visible', 'boolean', 'eq', [
41
            'sortable' => false,
42
            'form_options' => [
43
                'label' => 'admin.news.list.visible',
44
            ]
45
        ]);
46
47
        $datasource->addField('creator_email', 'text', 'like', [
48
            'field' => 'creatorEmail',
49
            'sortable' => true,
50
            'form_options' => [
51
                'label' => 'admin.news.list.creator_email',
52
            ]
53
        ]);
54
55
        $datasource->setMaxResults(10);
56
57
        return $datasource;
58
    }
59
}
60