| Conditions | 4 |
| Paths | 2 |
| Total Lines | 52 |
| Code Lines | 44 |
| 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 | <? |
||
| 8 | function renderDocument($document, $cmsPrefix, $slugPrefix = '', $request) |
||
| 9 | { ?> |
||
| 10 | <div class="grid-box-10"> |
||
| 11 | <h3> |
||
| 12 | <a class="btn documentTitle" href="<?= $request::$subfolders ?><?= $cmsPrefix ?>/documents/edit-document?slug=<?= $slugPrefix . $document->slug ?>" title="Edit"> |
||
| 13 | <i class="fa fa-file-text-o"></i> |
||
| 14 | <small class="state <?= strtolower($document->state) ?>"> |
||
| 15 | <i class="fa <?= $document->state == 'published' ? 'fa-check-circle-o' : 'fa-times-circle-o' ?>"></i></small> |
||
| 16 | <?= $document->title ?> |
||
| 17 | </a> |
||
| 18 | <? if ($document->unpublishedChanges) : ?> |
||
| 19 | <small class="small unpublished-changes">Unpublished Changes</small> |
||
| 20 | <? endif ?> |
||
| 21 | <small class="small documentType"><?= $document->documentType ?></small> |
||
| 22 | <small class="small lastModified" title="<?= date('r', $document->lastModificationDate) ?>"> |
||
| 23 | <span class="label">Modified:</span> |
||
| 24 | <?= \CloudControl\Cms\cc\StringUtil::timeElapsedString($document->lastModificationDate) ?> |
||
| 25 | </small> |
||
| 26 | <small class="small lastModifiedBy"> |
||
| 27 | <span class="label">By:</span> |
||
| 28 | <?= $document->lastModifiedBy ?> |
||
| 29 | </small> |
||
| 30 | </h3> |
||
| 31 | </div> |
||
| 32 | <div class="documentActions grid-box-2"> |
||
| 33 | <? renderAction( |
||
| 34 | $document->state == 'unpublished' || $document->unpublishedChanges, |
||
| 35 | 'Publish', |
||
| 36 | 'publish', |
||
| 37 | $request::$subfolders . $cmsPrefix . '/documents/publish-document?slug=' . $slugPrefix . $document->slug, |
||
| 38 | 'check'); ?> |
||
| 39 | <? renderAction( |
||
| 40 | $document->state == 'published', |
||
| 41 | 'Unpublish', |
||
| 42 | 'unpublish', |
||
| 43 | $request::$subfolders . $cmsPrefix . '/documents/unpublish-document?slug=' . $slugPrefix . $document->slug, |
||
| 44 | 'times'); ?> |
||
| 45 | <? renderAction( |
||
| 46 | true, |
||
| 47 | 'Edit', |
||
| 48 | '', |
||
| 49 | $request::$subfolders . $cmsPrefix . '/documents/edit-document?slug=' . $slugPrefix . $document->slug, |
||
| 50 | 'pencil'); ?> |
||
| 51 | <? renderAction( |
||
| 52 | $document->state == 'unpublished', |
||
| 53 | 'Delete', |
||
| 54 | 'error', |
||
| 55 | $request::$subfolders . $cmsPrefix . '/documents/delete-document?slug=' . $slugPrefix . $document->slug, |
||
| 56 | 'trash', |
||
| 57 | 'return confirm(\'Are you sure you want to delete this document?\');'); ?> |
||
|
|
|||
| 58 | </div> |
||
| 59 | <? } ?> |
||
| 60 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: