Completed
Push — 2.0 ( ee0168...76e968 )
by Marco
11:26
created

ProcessEntityTrait::setMaxtime()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
1
<?php namespace Comodojo\Extender\Traits;
2
3
/**
4
 * @package     Comodojo Extender
5
 * @author      Marco Giovinazzi <[email protected]>
6
 * @license     MIT
7
 *
8
 * LICENSE:
9
 *
10
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
11
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
15
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
16
 * THE SOFTWARE.
17
 */
18
19
trait ProcessEntityTrait {
20
21
    /**
22
     * @var integer
23
     *
24
     * @ORM\Column(name="niceness", type="integer", nullable=false)
25
     */
26
    protected $niceness = 0;
27
28
    /**
29
     * @var integer
30
     *
31
     * @ORM\Column(name="maxtime", type="integer", nullable=false)
32
     */
33
    protected $maxtime = 600;
34
35
    /**
36
     * Get desired process niceness
37
     *
38
     * @return int
39
     */
40
    public function getNiceness() {
41
42
        return $this->niceness;
43
44
    }
45
46
    /**
47
     * Set desired process niceness
48
     *
49
     * @param int $niceness An integer between -20 and +20, default 0
50
     * @return Schedule
51
     */
52
    public function setNiceness($niceness) {
53
54
        $niceness = DataFilter::filterInteger($niceness, -20, 20);
55
56
        $this->niceness = $niceness;
57
58
        return $this;
59
60
    }
61
62
    /**
63
     * Get maximum time allowed for process to terminate
64
     *
65
     * @return int
66
     */
67
    public function getMaxtime() {
68
69
        return $this->maxtime;
70
71
    }
72
73
    /**
74
     * Set maximum time given to process to terminate
75
     *
76
     * @param int $secs Seconds as an integer >0, default 600 (10 minutes)
77
     * @return Schedule
78
     */
79
    public function setMaxtime($secs) {
80
81
        $secs = DataFilter::filterInteger($secs, 1, PHP_INT_MAX, 600);
82
83
        $this->maxtime = $secs;
84
85
        return $this;
86
87
    }
88
89
}
90