Completed
Push — master ( bcd851...8f09ac )
by Scott
03:07
created

Application::checkAppId()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
namespace Sjdaws\NewRelicApi;
4
5
use Sjdaws\NewRelicApi\Application\Deployments;
6
7
class Application extends Resource
8
{
9
    /**
10
     * The application id currently being worked on
11
     *
12
     * @param integer
13
     */
14
    protected $appId;
15
16
    /**
17
     * Set the application id
18
     *
19
     * @param  integer       $appId
20
     * @throws Exception     If appId is not a valid integer
21
     * @return Application
22
     */
23
    public function appId($appId)
24
    {
25
        // If app id isn't a positive integer it's invalid
26
        $this->checkInteger('application id', $appId, true);
27
        $this->appId = $appId;
28
    }
29
30
    /**
31
     * Check we have an application id before continuing
32
     *
33
     * @throws Exception
34
     * @return boolean
35
     */
36
    protected function checkAppId()
37
    {
38
        // We must have an app id set or a deployment can't be recorded
39
        if (!$this->appId) {
40
            $this->throwException('No application id specified. Application id is mandatory when using this method.');
41
        }
42
43
        return true;
44
    }
45
46
    /**
47
     * Create a new deployment instance
48
     *
49
     * @return Deployments
50
     */
51
    public function deployments()
52
    {
53
        $deployments = new Deployments($this->apiKey, $this->logger);
54
55
        if ($this->appId) {
56
            $deployments->appId($this->appId);
57
        }
58
59
        return $deployments;
60
    }
61
}
62