Passed
Branch develop (56c45f)
by Jens
02:42
created

renderDocument()   B

Complexity

Conditions 4
Paths 2

Size

Total Lines 51
Code Lines 49

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 4
eloc 49
nc 2
nop 4
dl 0
loc 51
rs 8.8981
c 3
b 0
f 0

How to fix   Long Method   

Long Method

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:

1
<?
2
/**
3
 * @param \CloudControl\Cms\storage\entities\Document $document
4
 * @param string $cmsPrefix
5
 * @param string $slugPrefix
6
 * @param \CloudControl\Cms\cc\Request $request
7
 */
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?\');'); ?>
0 ignored issues
show
Bug introduced by
'return confirm('Are you...lete this document?');' of type string is incompatible with the type boolean expected by parameter $onclick of renderAction(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

57
          /** @scrutinizer ignore-type */ 'return confirm(\'Are you sure you want to delete this document?\');'); ?>
Loading history...
58
  </div>
59
<? } ?>
60