| Conditions | 11 |
| Paths | 16 |
| Total Lines | 52 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 24 | public function __construct($name, Order $order, Member $member = null) |
||
| 25 | { |
||
| 26 | if (!$member) { |
||
| 27 | $member = $order->Member(); |
||
| 28 | } |
||
| 29 | if (!$member) { |
||
| 30 | $member = new Member(); |
||
| 31 | } |
||
| 32 | $orderSteps = OrderStep::get(); |
||
| 33 | $where = '"HideStepFromCustomer" = 0'; |
||
| 34 | $currentStep = $order->CurrentStepVisibleToCustomer(); |
||
| 35 | if ($member->IsShopAdmin()) { |
||
| 36 | $currentStep = $order->MyStep(); |
||
| 37 | } else { |
||
| 38 | $currentStep = $order->CurrentStepVisibleToCustomer(); |
||
| 39 | $orderSteps = $orderSteps |
||
| 40 | ->filter(array('HideStepFromCustomer' => 0)); |
||
| 41 | } |
||
| 42 | $future = false; |
||
| 43 | $html = ' |
||
| 44 | <div class="orderStepField"> |
||
| 45 | <ol>'; |
||
| 46 | if ($orderSteps->count()) { |
||
| 47 | foreach ($orderSteps as $orderStep) { |
||
| 48 | if ($orderStep->HideFromEveryone()) { |
||
| 49 | continue; |
||
| 50 | } |
||
| 51 | $description = ''; |
||
| 52 | if ($member->IsShopAdmin()) { |
||
| 53 | if ($orderStep->Description) { |
||
| 54 | $description = ' title="'.Convert::raw2att($orderStep->Description).'" '; |
||
| 55 | } |
||
| 56 | } |
||
| 57 | $class = ''; |
||
| 58 | if ($orderStep->ID == $currentStep->ID) { |
||
| 59 | $future = true; |
||
| 60 | $class .= ' current'; |
||
| 61 | } elseif ($future) { |
||
| 62 | $class .= ' todo'; |
||
| 63 | } else { |
||
| 64 | $class .= ' done'; |
||
| 65 | } |
||
| 66 | $html .= '<li class="'.$class.'" '.$description.'><a href="'.$orderStep->CMSEditLink().'">'.$orderStep->Title.'</a></li>'; |
||
| 67 | } |
||
| 68 | } else { |
||
| 69 | $html .= 'no steps'; |
||
| 70 | } |
||
| 71 | $html .= '</ol><div class="clear"></div></div>'; |
||
| 72 | $this->content = $html; |
||
| 73 | Requirements::themedCSS('OrderStepField', 'ecommerce'); |
||
| 74 | parent::__construct($name); |
||
| 75 | } |
||
| 76 | |||
| 142 |
This check looks for
@paramannotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.