Completed
Push — 6.0 ( 800870...267f59 )
by yun
03:41 queued 17s
created

PaginatorService   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 28
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 19 3
A register() 0 4 2
1
<?php
2
// +----------------------------------------------------------------------
1 ignored issue
show
Coding Style introduced by
You must use "/**" style comments for a file comment
Loading history...
3
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
4
// +----------------------------------------------------------------------
5
// | Copyright (c) 2006~2019 http://thinkphp.cn All rights reserved.
6
// +----------------------------------------------------------------------
7
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
8
// +----------------------------------------------------------------------
9
// | Author: yunwuxin <[email protected]>
10
// +----------------------------------------------------------------------
11
declare (strict_types = 1);
12
13
namespace think\service;
14
15
use think\Paginator;
16
use think\paginator\driver\Bootstrap;
17
use think\Service;
18
19
class PaginatorService extends Service
1 ignored issue
show
Coding Style introduced by
Missing doc comment for class PaginatorService
Loading history...
20
{
21
    public function register()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function register()
Loading history...
22
    {
23
        if (!$this->app->bound(Paginator::class)) {
24
            $this->app->bind(Paginator::class, Bootstrap::class);
25
        }
26
    }
27
28
    public function boot()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function boot()
Loading history...
29
    {
30
        Paginator::maker(function (...$args) {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
31
            return $this->app->make(Paginator::class, $args, true);
32
        });
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
33
34
        Paginator::currentPathResolver(function () {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
35
            return $this->app->request->baseUrl();
36
        });
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
37
38
        Paginator::currentPageResolver(function ($varPage = 'page') {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
39
40
            $page = $this->app->request->param($varPage);
41
42
            if (filter_var($page, FILTER_VALIDATE_INT) !== false && (int) $page >= 1) {
43
                return (int) $page;
44
            }
45
46
            return 1;
47
        });
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
48
    }
49
}
50