Native::setReceiveModeExcept()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
namespace FMUP\Queue\Channel\Settings;
3
4
use FMUP\Queue\Channel\Settings;
5
6
/**
7
 * Settings for native driver
8
 * @package FMUP\Queue\Channel\Settings
9
 */
10
class Native extends Settings
11
{
12
    private $settings = array();
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
13
    //(bool) force size without error if message in queue is bigger than defined message size
14
    // (@see PARAM_MAX_MESSAGE_SIZE) (default false)
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
15
    const PARAM_RECEIVE_FORCE_SIZE = 'PARAM_RECEIVE_FORCE_SIZE';
16
    //(bool) will receive a message different than the specified type if set to true (default false)
17
    const PARAM_RECEIVE_MODE_EXCEPT = 'PARAM_RECEIVE_MODE_EXCEPT';
18
19 2
    public function define($setting, $value)
20
    {
21
        switch ($setting) {
22 2
            case self::PARAM_RECEIVE_FORCE_SIZE:
23 1
                $this->setReceiveForceSize($value);
24 1
                break;
25 2
            case self::PARAM_RECEIVE_MODE_EXCEPT:
26 1
                $this->setReceiveModeExcept($value);
27 1
                break;
28
            default:
29 1
                parent::define($setting, $value);
30
        }
31 1
        return $this;
32
    }
33
34
    /**
35
     * Define if process force size without error if message in queue is bigger
36
     * than defined message size (default false)
37
     *
38
     * @see PARAM_MAX_MESSAGE_SIZE
39
     * @param bool|false $receiveForceSize
40
     * @return $this
41
     */
42 1
    public function setReceiveForceSize($receiveForceSize = false)
43
    {
44 1
        $this->settings[self::PARAM_RECEIVE_FORCE_SIZE] = (bool)$receiveForceSize;
45 1
        return $this;
46
    }
47
48
    /**
49
     * Get if process force size without error if message in queue is bigger than defined message size (default false)
50
     * @see PARAM_MAX_MESSAGE_SIZE
51
     * @return bool
52
     */
53 3
    public function getReceiveForceSize()
54
    {
55 3
        return isset($this->settings[self::PARAM_RECEIVE_FORCE_SIZE])
56 1
            ? (bool)$this->settings[self::PARAM_RECEIVE_FORCE_SIZE]
57 3
            : false;
58
    }
59
60
    /**
61
     * Define if process will receive a message different than the specified type if set to true (default false)
62
     * @param bool|false $receiveModeExcept
63
     * @return $this
64
     */
65 1
    public function setReceiveModeExcept($receiveModeExcept = false)
66
    {
67 1
        $this->settings[self::PARAM_RECEIVE_MODE_EXCEPT] = (bool)$receiveModeExcept;
68 1
        return $this;
69
    }
70
71
    /**
72
     * Get if process will receive a message different than the specified type if set to true (default false)
73
     * @return bool
74
     */
75 3
    public function getReceiveModeExcept()
76
    {
77 3
        return isset($this->settings[self::PARAM_RECEIVE_MODE_EXCEPT])
78 1
            ? (bool)$this->settings[self::PARAM_RECEIVE_MODE_EXCEPT]
79 3
            : false;
80
    }
81
}
82