Issues (107)

src/Cronjob.php (7 issues)

1
<?php
2
3
namespace Puerari\Cwp;
4
5
/**
6
 * @trait Cronjob
7
 * @package Puerari\Cwp
8
 * @author Leandro Puerari <[email protected]>
9
 */
10
trait Cronjob
11
{
12
    /**
13
     * @param string $user : User owners of the scheduled tasks
14
     * @param string $execute : Frequency with which to execute the cron Example: * * * * * *
15
     * @param string $command : Command to execute, Example: /usr/bin/php test.php
16
     * @return string|bool: false on failure, result on success (JSON / XML)
17
     * status -> OK
18
     * status -> Error -> user does not exist
19
     */
20
    public function createCronJob(string $user, string $execute, string $command)
21
    {
22
        $this->data = compact('user', 'execute', 'command');
0 ignored issues
show
Bug Best Practice introduced by
The property data does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
23
        $this->data['debug'] = $this->debug;
24
        $this->data['action'] = 'add';
25
        $this->cwpuri = 'cronjobsusers';
0 ignored issues
show
Bug Best Practice introduced by
The property cwpuri does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
26
        return $this->execCurl();
0 ignored issues
show
It seems like execCurl() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

26
        return $this->/** @scrutinizer ignore-call */ execCurl();
Loading history...
27
    }
28
29
    /**
30
     * @param string $user : User owners of the scheduled tasks
31
     * @param string $execute : Frequency with which to execute the cron Example: * * * * * *
32
     * @param string $command : Command to execute, Example: /usr/bin/php test.php
33
     * @return string|bool: false on failure, result on success (JSON / XML)
34
     * status -> OK
35
     * status -> Error -> user does not exist
36
     * status -> Error -> domain does not exist
37
     */
38
    public function deleteCronJob(string $user, string $execute, string $command)
39
    {
40
        $this->data = compact('user', 'execute', 'command');
0 ignored issues
show
Bug Best Practice introduced by
The property data does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
41
        $this->data['debug'] = $this->debug;
42
        $this->data['action'] = 'del';
43
        $this->cwpuri = 'cronjobsusers';
0 ignored issues
show
Bug Best Practice introduced by
The property cwpuri does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
44
        return $this->execCurl();
45
    }
46
47
    /**
48
     * @param string $user : Account user name
49
     * @return string|bool: false on failure, result on success (JSON / XML)
50
     * status -> OK
51
     * status -> Error -> user does not exist
52
     */
53
    public function listCronJobs(string $user)
54
    {
55
        $this->data = compact('user');
0 ignored issues
show
Bug Best Practice introduced by
The property data does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
56
        $this->data['debug'] = $this->debug;
57
        $this->data['action'] = 'list';
58
        $this->cwpuri = 'cronjobsusers';
0 ignored issues
show
Bug Best Practice introduced by
The property cwpuri does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
59
        return $this->execCurl();
60
    }
61
}
62