Completed
Push — master ( d66c3c...7db86c )
by Alex
05:11
created

request   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 60
c 0
b 0
f 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A requestVersionTooLow() 0 4 1
A requestVersionIsBiggerThanProtocolVersion() 0 4 1
A requestDescriptionInvalidVersionHeader() 0 4 1
A requestDescriptionUnSupportedVersion() 0 4 1
1
<?php
2
namespace POData\Common\Messages;
3
4
trait request
5
{
6
    /**
7
     * Format a message to show error when client requested version is
8
     * lower than the version required to intercept the response.
9
     *
10
     * @param string $requestedVersion The client requested version
11
     * @param string $requiredVersion  The minimum version required to
12
     *                                 intercept the response
13
     *
14
     * @return string The formatted message
15
     */
16
    public static function requestVersionTooLow($requestedVersion, $requiredVersion)
17
    {
18
        return "Request version '$requestedVersion' is not supported for the request payload. The only supported version is '$requiredVersion'.";
19
    }
20
21
    /**
22
     * Format a message to show error when version required to intercept
23
     * the response is greater than the configured maximum protocol version.
24
     *
25
     * @param string $requiredVersion   Required version
26
     * @param string $configuredVersion Configured version
27
     *
28
     * @return string The formatted message
29
     */
30
    public static function requestVersionIsBiggerThanProtocolVersion($requiredVersion, $configuredVersion)
31
    {
32
        return "The response requires that version $requiredVersion of the protocol be used, but the MaxProtocolVersion of the data service is set to $configuredVersion.";
33
    }
34
35
    /**
36
     * Format a message to show error when value of DataServiceVersion or
37
     * MaxDataServiceVersion is invalid.
38
     *
39
     * @param string $versionAsString String value of the version
40
     * @param string $headerName      Header name
41
     *
42
     * @return string The formatted message
43
     */
44
    public static function requestDescriptionInvalidVersionHeader($versionAsString, $headerName)
45
    {
46
        return "The header $headerName has malformed version value $versionAsString";
47
    }
48
49
    /**
50
     * Format a message to show error when value of DataServiceVersion or
51
     * MaxDataServiceVersion is invalid.
52
     *
53
     * @param string $requestHeaderName Name of the request header
54
     * @param string $requestedVersion  Requested version
55
     * @param string $availableVersions Available versions
56
     *
57
     * @return string The formatted message
58
     */
59
    public static function requestDescriptionUnSupportedVersion($requestHeaderName, $requestedVersion, $availableVersions)
60
    {
61
        return "The version value $requestedVersion in the header $requestHeaderName is not supported, available versions are $availableVersions";
62
    }
63
}
64