Completed
Push — master ( bc825a...1aba9a )
by William
06:03
created

SyncGithubIssueStatesShell::main()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 36
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 18
CRAP Score 2.0005

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 25
nc 2
nop 0
dl 0
loc 36
ccs 18
cts 19
cp 0.9474
crap 2.0005
rs 9.52
c 2
b 0
f 0
1
<?php
2
/* vim: set expandtab sw=4 ts=4 sts=4: */
3
4
/**
5
 * Sync Github issue states Shell.
6
 *
7
 * phpMyAdmin Error reporting server
8
 * Copyright (c) phpMyAdmin project (https://www.phpmyadmin.net/)
9
 *
10
 * Licensed under The MIT License
11
 * For full copyright and license information, please see the LICENSE.txt
12
 * Redistributions of files must retain the above copyright notice.
13
 *
14
 * @copyright Copyright (c) phpMyAdmin project (https://www.phpmyadmin.net/)
15
 * @license   https://opensource.org/licenses/mit-license.php MIT License
16
 *
17
 * @see      https://www.phpmyadmin.net/
18
 */
19
20
namespace App\Shell;
21
22
use Cake\Console\Shell;
23
use Cake\Core\Configure;
24
use Cake\Log\Log;
25
use Cake\Http\ServerRequest;
26
use Cake\Http\Response;
27
use Cake\Routing\DispatcherFactory;
28
use Cake\Routing\Router;
29
30
/**
31
 * Sync Github issue states Shell.
32
 */
33
class SyncGithubIssueStatesShell extends Shell
34
{
35
    public function initialize()
36
    {
37
        parent::initialize();
38
    }
39
40 1
    public function main()
41
    {
42 1
        Log::debug(
43
            'STARTED: Job "'
44
                . 'github/sync_issue_status'
45
                . '" at '
46 1
                . date('d-m-Y G:i:s (e)'),
47 1
            ['scope' => 'cron_jobs']
48
        );
49
50
51 1
        Configure::write('CronDispatcher', true);
52 1
        if (PHP_SAPI === 'cli') {
53 1
            $dispatcher = DispatcherFactory::create();
54
55 1
            $request = new ServerRequest('github/sync_issue_status');
56 1
            $request = $request->addParams(
0 ignored issues
show
Deprecated Code introduced by
The function Cake\Http\ServerRequest::addParams() has been deprecated: 3.6.0 ServerRequest::addParams() is deprecated. Use `withParam()` or `withAttribute('params')` instead. ( Ignorable by Annotation )

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

56
            $request = /** @scrutinizer ignore-deprecated */ $request->addParams(

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
57 1
                Router::parse(
0 ignored issues
show
Deprecated Code introduced by
The function Cake\Routing\Router::parse() has been deprecated: 3.4.0 Use Router::parseRequest() instead. ( Ignorable by Annotation )

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

57
                /** @scrutinizer ignore-deprecated */ Router::parse(

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
58 1
                    $request->getPath(),
59 1
                    ''
60
                )
61
            );
62 1
            $dispatcher->dispatch(
63 1
                $request,
64 1
                new Response()
65
            );
66
        } else {
67
            exit;
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
68
        }
69
70 1
        Log::debug(
71
            'FINISHED: Job "'
72
                . 'github/sync_issue_status'
73
                . '" at '
74 1
                . date('d-m-Y G:i:s (e)'),
75 1
            ['scope' => 'cron_jobs']
76
        );
77 1
    }
78
}
79