Completed
Push — master ( 7fc3e1...d9b76d )
by Sam
12s queued 10s
created

ResultListMovies::getDateAddedColumn()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * ResultList implementation for movies
5
 *
6
 * @author Sam Stenvall <[email protected]>
7
 * @copyright Copyright &copy; Sam Stenvall 2014-
8
 * @license https://www.gnu.org/licenses/gpl.html The GNU General Public License v3.0
9
 */
10
class ResultListMovies extends ResultList
11
{
12
13
	public function getColumnDefinitions()
14
	{
15
		return array(
16
			$this->getLabelColumn(),
17
			$this->getYearColumn(),
18
			$this->getGenreColumn(),
19
			$this->getRatingColumn(),
20
			$this->getRuntimeColumn(),
21
			$this->getDateAddedColumn(),
22
		);
23
	}
24
25
	/**
26
	 * Returns the column definition for the rating column
27
	 * @return array
28
	 */
29
	private function getRatingColumn()
30
	{
31
		return array(
32
			'name'=>'rating',
33
			'header'=>Yii::t('MovieList', 'Rating'),
34
			'value'=>function($data) {
35
				/* @var $data Movie */
36
				echo $data->getRating();
37
			}
38
		);
39
	}
40
41
	/**
42
	 * Returns the column definition for the runtime column
43
	 * @return array
44
	 */
45 View Code Duplication
	private function getRuntimeColumn()
0 ignored issues
show
Duplication introduced by
This method 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...
46
	{
47
		return array(
48
			'name'=>'runtime',
49
			'header'=>Yii::t('GenericList', 'Runtime'),
50
			'value'=>function($data) {
51
				/* @var $data Movie */
52
				echo $data->getRuntimeString();
53
			}
54
		);
55
	}
56
57
58
	/**
59
	 * Returns the column definition for the dateadded column
60
	 * @return array
61
	 */
62
	private function getDateAddedColumn()
63
	{
64
		return [
65
			'name'   => 'dateadded',
66
			'header' => Yii::t('MovieList', 'Date added'),
67
			'value'  => function ($data) {
68
				/** @var Movie $data */
69
				echo $data->getDateAdded();
70
			},
71
		];
72
	}
73
}
74