Passed
Push — master ( d7fd6a...9124ff )
by Robbie
11:58
created

NewsHolder   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 38
Duplicated Lines 100 %

Importance

Changes 0
Metric Value
wmc 1
c 0
b 0
f 0
dl 38
loc 38
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A AllUpdates() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3 View Code Duplication
class NewsHolder extends DatedUpdateHolder {
0 ignored issues
show
Duplication introduced by
This class 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...
4
5
	private static $description = 'Container page for News Pages, provides news filtering and pagination';
0 ignored issues
show
introduced by
The private property $description is not used, and could be removed.
Loading history...
6
7
	private static $allowed_children = array('NewsPage');
0 ignored issues
show
introduced by
The private property $allowed_children is not used, and could be removed.
Loading history...
8
9
	private static $default_child = 'NewsPage';
0 ignored issues
show
introduced by
The private property $default_child is not used, and could be removed.
Loading history...
10
11
	private static $update_name = 'News';
0 ignored issues
show
introduced by
The private property $update_name is not used, and could be removed.
Loading history...
12
13
	private static $update_class = 'NewsPage';
0 ignored issues
show
introduced by
The private property $update_class is not used, and could be removed.
Loading history...
14
15
	private static $icon = 'cwp/images/icons/sitetree_images/news_listing.png';
0 ignored issues
show
introduced by
The private property $icon is not used, and could be removed.
Loading history...
16
17
	public $pageIcon =  'images/icons/sitetree_images/news_listing.png';
18
19
	private static $singular_name = 'News Holder';
0 ignored issues
show
introduced by
The private property $singular_name is not used, and could be removed.
Loading history...
20
21
	private static $plural_name = 'News Holders';
0 ignored issues
show
introduced by
The private property $plural_name is not used, and could be removed.
Loading history...
22
23
	/**
24
	 * Find all site's news items, based on some filters.
25
	 * Omitting parameters will prevent relevant filters from being applied. The filters are ANDed together.
0 ignored issues
show
Bug introduced by
The type The was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
26
	 *
27
	 * @param $className The name of the class to fetch.
28
	 * @param $parentID The ID of the holder to extract the news items from.
29
	 * @param $tagID The ID of the tag to filter the news items by.
30
	 * @param $dateFrom The beginning of a date filter range.
31
	 * @param $dateTo The end of the date filter range. If empty, only one day will be searched for.
32
	 * @param $year Numeric value of the year to show.
33
	 * @param $monthNumber Numeric value of the month to show.
34
	 *
35
	 * @returns DataList | PaginatedList
36
	 */
37
	public static function AllUpdates($className = 'NewsPage', $parentID = null, $tagID = null, $dateFrom = null,
38
			$dateTo = null, $year = null, $monthNumber = null) {
39
40
		return parent::AllUpdates($className, $parentID, $tagID, $dateFrom, $dateTo, $year, $monthNumber)->Sort('Date', 'DESC');
41
	}
42
}
43
44
class NewsHolder_Controller extends DatedUpdateHolder_Controller {
45
	private static $allowed_actions = array(
0 ignored issues
show
introduced by
The private property $allowed_actions is not used, and could be removed.
Loading history...
46
		'rss',
47
		'atom'
48
	);
49
50 View Code Duplication
	public function rss() {
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...
51
		$rss = new RSSFeed(
52
			$this->Updates()->sort('Created DESC')->limit(20),
53
			$this->Link('rss'),
54
			$this->getSubscriptionTitle()
55
		);
56
		$rss->setTemplate('NewsHolder_rss');
57
		return $rss->outputToBrowser();
58
	}
59
60 View Code Duplication
	public function atom() {
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...
61
		$atom = new CwpAtomFeed(
62
			$this->Updates()->sort('Created DESC')->limit(20),
63
			$this->Link('atom'),
64
			$this->getSubscriptionTitle()
65
		);
66
		$atom->setTemplate('NewsHolder_atom');
67
		return $atom->outputToBrowser();
68
	}
69
}
70