PageContent::show()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
use Jaxon\App\PageComponent;
4
use Jaxon\App\PageDatabagTrait;
5
6
/**
7
 * @databag page
8
 */
9
class PageContent extends PageComponent
10
{
11
    use PageDatabagTrait;
12
13
   /**
14
    * @inheritDoc
15
    */
16
   protected function bagName(): string
17
   {
18
       return 'page';
19
   }
20
21
   /**
22
    * @inheritDoc
23
    */
24
   protected function bagAttr(): string
25
   {
26
       return 'number';
27
   }
28
29
   /**
30
    * @inheritDoc
31
    */
32
    protected function limit(): int
33
    {
34
        return 10;
35
    }
36
 
37
    /**
38
     * @inheritDoc
39
     */
40
    protected function count(): int
41
    {
42
        return 150;
43
    }
44
 
45
   public function html():  string
46
    {
47
        return '<div style="margin-bottom:10px;font-weight:bold;">' .
48
            $this->bag('page')->get('title') .
49
            '</div>Showing page number ' . $this->currentPage();
50
    }
51
52
    public function showPage(int $pageNumber)
53
    {
54
        // Get the paginator. This will also set the final page number value.
55
        $paginator = $this->paginator($pageNumber);
56
        // Render the page content.
57
        $this->render();
58
        // Render the pagination component.
59
        $paginator->render($this->rq()->showPage(je()->rd()->page()));
0 ignored issues
show
Bug introduced by
The method showPage() does not exist on Jaxon\Script\Call\JxnCall. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

59
        $paginator->render($this->rq()->/** @scrutinizer ignore-call */ showPage(je()->rd()->page()));
Loading history...
60
    }
61
62
    public function show()
63
    {
64
        $title = 'This is the page title';
65
        $this->bag('page')->set('title', $title);
66
        $this->showPage(1);
67
    }
68
}
69
70
jaxon()->app()->setup(configFile('component.php'));
71