InvalidResponseException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 34
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 2
A getParameterName() 0 4 1
1
<?php
2
3
/**
4
 * PHP Client for DDN Web Object Scalar (WOS) API
5
 *
6
 * @package Wosclient
7
 * @author  Casey McLaughlin <[email protected]>
8
 * @license http://opensource.org/licenses/MIT MIT
9
 * @link    https://github.com/caseyamcl/wosclient
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 *
14
 * ------------------------------------------------------------------
15
 */
16
17
namespace WosClient\Exception;
18
19
/**
20
 * Missing Header Exception
21
 *
22
 * This exception is thrown when a WosClient library expects a header
23
 * to be present in the HTTP response, but it does not exist
24
 *
25
 * @author Casey McLaughlin <[email protected]>
26
 */
27
class InvalidResponseException extends WosException
28
{
29
    /**
30
     * @var string
31
     */
32
    private $parameterName;
33
34
    /**
35
     * InvalidResponseException constructor.
36
     *
37
     * @param string $oarameterName The parameter/HTTP header that was expected in the response (e.g. 'x-ddn-oid')
38
     * @param string $requestAction The action that was requested, if known (e.g., 'getMetdata()')
39
     */
40
    public function __construct($oarameterName, $requestAction = '')
41
    {
42
        $this->parameterName = $oarameterName;
43
44
        $message = sprintf(
45
            "Response did not contain '%s' header. Are you sure that you made a %s to a WOS Server?",
46
            $oarameterName,
47
            $requestAction ? $requestAction . ' request' : 'request'
48
        );
49
50
        parent::__construct($message);
51
    }
52
53
    /**
54
     * @return string
55
     */
56
    public function getParameterName()
57
    {
58
        return $this->parameterName;
59
    }
60
}
61