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

orderByPathSegmentOrderBySubPathSegmentArgumentShouldBeNonEmptyArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace POData\Common\Messages;
3
4
trait orderByInfo
5
{
6
    /**
7
     * Message to show error when the orderByPathSegments argument found as
8
     * not a non-empty array.
9
     *
10
     * @return string The message
11
     */
12
    public static function orderByInfoPathSegmentsArgumentShouldBeNonEmptyArray()
13
    {
14
        return 'The argument orderByPathSegments should be a non-empty array';
15
    }
16
17
    /**
18
     * Message to show error when the navigationPropertiesUsedInTheOrderByClause
19
     * argument found as neither null or a non-empty array.
20
     *
21
     * @return string The message
22
     */
23
    public static function orderByInfoNaviUsedArgumentShouldBeNullOrNonEmptyArray()
24
    {
25
        return 'The argument navigationPropertiesUsedInTheOrderByClause should be either null or a non-empty array';
26
    }
27
28
    /**
29
     * Message to show error when the orderBySubPathSegments argument found as
30
     * not a non-empty array.
31
     *
32
     * @return string The message
33
     */
34
    public static function orderByPathSegmentOrderBySubPathSegmentArgumentShouldBeNonEmptyArray()
35
    {
36
        return 'The argument orderBySubPathSegments should be a non-empty array';
37
    }
38
39
    /**
40
     * Format a message to show error when parser failed to resolve a
41
     * property in orderby path.
42
     *
43
     * @param string $resourceTypeName The name of resource type
44
     * @param string $propertyName     Sub path segment, that comes after the
45
     *                                 segment of type  $resourceTypeName
46
     *
47
     * @return string The formatted message
48
     */
49
    public static function orderByParserPropertyNotFound($resourceTypeName, $propertyName)
50
    {
51
        return  "Error in the 'orderby' clause. Type '$resourceTypeName' does not have a property named '$propertyName'.";
52
    }
53
54
    /**
55
     * Format a message to show error when found a bag property used
56
     * in orderby clause.
57
     *
58
     * @param string $bagPropertyName The name of the bag property
59
     *
60
     * @return string The formatted message
61
     */
62
    public static function orderByParserBagPropertyNotAllowed($bagPropertyName)
63
    {
64
        return "orderby clause does not support Bag property in the path, the property '$bagPropertyName' is a bag property";
65
    }
66
67
    /**
68
     * Format a message to show error when found a primitve property used as
69
     * intermediate segment in orderby clause.
70
     *
71
     * @param string $propertyName The name of primitive property
72
     *
73
     * @return string The formatted message
74
     */
75
    public static function orderByParserPrimitiveAsIntermediateSegment($propertyName)
76
    {
77
        return "The primitive property '$propertyName' cannnot be used as intermediate segment, it should be last segment";
78
    }
79
80
    /**
81
     * Format a message to show error when found binary property used as sort key.
82
     *
83
     * @param string $binaryPropertyName The name of binary property
84
     *
85
     * @return string The formatted message
86
     */
87
    public static function orderByParserSortByBinaryPropertyNotAllowed($binaryPropertyName)
88
    {
89
        return "Binary property is not allowed in orderby clause, '$binaryPropertyName'";
90
    }
91
92
    /**
93
     * Format a message to show error when found a resource set reference
94
     * property in the oriderby clause.
95
     *
96
     * @param string $propertyName The name of resource set reference property
97
     * @param string $definedType  Defined type
98
     *
99
     * @return string The formatted message
100
     */
101
    public static function orderByParserResourceSetReferenceNotAllowed($propertyName, $definedType)
102
    {
103
        return "Navigation property points to a collection cannot be used in orderby clause, The property '$propertyName' defined on type '$definedType' is such a property";
104
    }
105
106
    /**
107
     * Format a message to show error when a navigation property is used as
108
     * sort key in orderby clause.
109
     *
110
     * @param string $navigationPropertyName The name of the navigation property
111
     *
112
     * @return string The formatted message
113
     */
114
    public static function orderByParserSortByNavigationPropertyIsNotAllowed($navigationPropertyName)
115
    {
116
        return "Navigation property cannot be used as sort key, '$navigationPropertyName'";
117
    }
118
119
    /**
120
     * Format a message to show error when a complex property is used as
121
     * sort key in orderby clause.
122
     *
123
     * @param string $complexPropertyName The name of the complex property
124
     *
125
     * @return string The formatted message
126
     */
127
    public static function orderByParserSortByComplexPropertyIsNotAllowed($complexPropertyName)
128
    {
129
        return "Complex property cannot be used as sort key, the property '$complexPropertyName' is a complex property";
130
    }
131
132
    /**
133
     * Message to show error when orderby parser found unexpected state.
134
     *
135
     * @return string The error message
136
     */
137
    public static function orderByParserUnExpectedState()
138
    {
139
        return 'Unexpected state while parsing orderby clause';
140
    }
141
142
    /**
143
     * Message to show error when orderby parser come across a type
144
     * which is not expected.
145
     *
146
     * @return string The message
147
     */
148
    public static function orderByParserUnexpectedPropertyType()
149
    {
150
        return 'Property type unexpected';
151
    }
152
153
    /**
154
     * Format a message to show error when the orderby parser fails to
155
     * create an instance of request uri resource type.
156
     *
157
     * @return string The formatted message
158
     */
159
    public static function orderByParserFailedToCreateDummyObject()
160
    {
161
        return 'OrderBy Parser failed to create dummy object from request uri resource type';
162
    }
163
164
    /**
165
     * Format a message to show error when orderby parser failed to
166
     * access some of the properties of dummy object.
167
     *
168
     * @param string $propertyName     Property name
169
     * @param string $parentObjectName Parent object name
170
     *
171
     * @return string The formatted message
172
     */
173
    public static function orderByParserFailedToAccessOrInitializeProperty($propertyName, $parentObjectName)
174
    {
175
        return "OrderBy parser failed to access or initialize the property $propertyName of $parentObjectName";
176
    }
177
178
}
179