Conditions | 17 |
Paths | 3 |
Total Lines | 32 |
Code Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
28 | public function Pages() |
||
29 | { |
||
30 | if (!$this->initialised) { |
||
31 | $this->parentPages = array(); |
||
32 | $page = $this->owner; |
||
33 | $i = 0; |
||
|
|||
34 | while ( |
||
35 | $page |
||
36 | && (!self::$maxDepth || sizeof($this->parentPages) < self::$maxDepth) |
||
37 | && (!self::$stopAtPageType || $page->ClassName != self::$stopAtPageType) |
||
38 | ) { |
||
39 | if (self::$showHidden || $page->ShowInMenus || ($page->ID == $this->owner->ID)) { |
||
40 | if ($page->URLSegment == self::$homeURLSegment) { |
||
41 | $this->hasHome = true; |
||
42 | } |
||
43 | if ($page->ID == $this->owner->ID) { |
||
44 | $page->isSelf = true; |
||
45 | } |
||
46 | |||
47 | if ((!$page->isSelf) || ($page->isSelf) && (self::$includeSelf)) { |
||
48 | array_unshift($this->parentPages, $page); |
||
49 | } |
||
50 | } |
||
51 | $page = $page->Parent; |
||
52 | } |
||
53 | if ((!$this->hasHome) && (self::$includeHome)) { |
||
54 | array_unshift($this->parentPages, DataObject::get_one('SiteTree', "`URLSegment` = '" . self::$homeURLSegment . "'")); |
||
55 | } |
||
56 | |||
57 | $this->initialised = true; |
||
58 | } |
||
59 | return new ArrayList($this->parentPages); |
||
60 | } |
||
119 |