Completed
Push — master ( dac7df...b079db )
by Daniel
03:09
created

DiscoverOptions   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 2
cbo 1
dl 0
loc 76
ccs 0
cts 14
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getMaximumWaitTime() 0 8 2
A setMaximumWaitTime() 0 5 1
A getSearchTarget() 0 8 2
A setSearchTarget() 0 5 1
1
<?php
2
/**
3
 * This file is part of the Ssdp project.
4
 *
5
 * @author Daniel Schröder <[email protected]>
6
 */
7
8
namespace GravityMedia\Ssdp\Options;
9
10
use GravityMedia\Ssdp\SearchTarget;
11
12
/**
13
 * Discover request options class
14
 *
15
 * @package GravityMedia\Ssdp\Request\Options
16
 */
17
class DiscoverOptions
18
{
19
    /**
20
     * Default maximum wait time (seconds to delay response)
21
     */
22
    const DEFAULT_MAXIMUM_WAIT_TIME = 1;
23
24
    /**
25
     * Default search target
26
     */
27
    const DEFAULT_SEARCH_TARGET = 'ssdp:all';
28
29
    /**
30
     * @var int
31
     */
32
    protected $maximumWaitTime;
33
34
    /**
35
     * @var SearchTarget
36
     */
37
    protected $searchTarget;
38
39
    /**
40
     * Get maximum wait time
41
     *
42
     * @return int
43
     */
44
    public function getMaximumWaitTime()
45
    {
46
        if (null === $this->maximumWaitTime) {
47
            return self::DEFAULT_MAXIMUM_WAIT_TIME;
48
        }
49
50
        return $this->maximumWaitTime;
51
    }
52
53
    /**
54
     * Set maximum wait time
55
     *
56
     * @param int $maximumWaitTime
57
     *
58
     * @return $this
59
     */
60
    public function setMaximumWaitTime($maximumWaitTime)
61
    {
62
        $this->maximumWaitTime = $maximumWaitTime;
63
        return $this;
64
    }
65
66
    /**
67
     * Get search target
68
     *
69
     * @return SearchTarget
70
     */
71
    public function getSearchTarget()
72
    {
73
        if (null === $this->searchTarget) {
74
            return SearchTarget::fromString(self::DEFAULT_SEARCH_TARGET);
75
        }
76
77
        return $this->searchTarget;
78
    }
79
80
    /**
81
     * Set search target
82
     *
83
     * @param SearchTarget $searchTarget
84
     *
85
     * @return $this
86
     */
87
    public function setSearchTarget(SearchTarget $searchTarget)
88
    {
89
        $this->searchTarget = $searchTarget;
90
        return $this;
91
    }
92
}
93