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

metadataAssociationType   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 44
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A metadataAssociationTypeSetBidirectionalAssociationMustReturnSameResourceAssociationSetFromBothEnd() 0 4 1
A metadataAssociationTypeSetMultipleAssociationSetsForTheSameAssociationTypeMustNotReferToSameEndSets() 0 4 1
A metadataAssociationTypeSetInvalidGetDerivedTypesReturnType() 0 4 1
1
<?php
2
namespace POData\Common\Messages;
3
4
trait metadataAssociationType
5
{
6
    /**
7
     * A message to show error when
8
     * IMetadataProvider::GetResourceAssociationSet() returns different
9
     * AssociationSet when called with 'ResourceAssociationSetEnd' instances that
10
     * are expected to the ends of same association set.
11
     *
12
     * @return string The error message
13
     */
14
    public static function metadataAssociationTypeSetBidirectionalAssociationMustReturnSameResourceAssociationSetFromBothEnd()
15
    {
16
        return 'When the ResourceAssociationSet is bidirectional, IMetadataProvider::getResourceAssociationSet() must return the same ResourceAssociationSet when call from both ends.';
17
    }
18
19
    /**
20
     * Format a message to show error when multiple ResourceAssociationSets
21
     * have a ResourceAssociationSetEnd referring to the
22
     * same EntitySet through the same AssociationType.
23
     *
24
     * @param string $resourceSet1Name Name of the first association set
25
     * @param string $resourceSet2Name Name of the second association set
26
     * @param string $entitySetName    Name of the entity set
27
     *
28
     * @return string The formatted message
29
     */
30
    public static function metadataAssociationTypeSetMultipleAssociationSetsForTheSameAssociationTypeMustNotReferToSameEndSets($resourceSet1Name, $resourceSet2Name, $entitySetName)
31
    {
32
        return "ResourceAssociationSets '$resourceSet1Name' and '$resourceSet2Name' have a ResourceAssociationSetEnd referring to the same EntitySet '$entitySetName' through the same AssociationType. Make sure that if two or more AssociationSets refer to the same AssociationType, the ends must not refer to the same EntitySet. (this could happen if multiple entity sets have entity types that have a common ancestor and the ancestor has a property of derived entity types)";
33
    }
34
35
    /**
36
     * Format a message to show error when IDSMP::getDerivedTypes returns a
37
     * type which is not null or array of ResourceType.
38
     *
39
     * @param string $resourceTypeName Resource type name
40
     *
41
     * @return string The formatted message
42
     */
43
    public static function metadataAssociationTypeSetInvalidGetDerivedTypesReturnType($resourceTypeName)
44
    {
45
        return "Return type of IDSMP::getDerivedTypes should be either null or array of 'ResourceType', check implementation of IDSMP::getDerivedTypes for the resource type '$resourceTypeName'.";
46
    }
47
}
48