@@ -53,6 +53,11 @@ discard block |
||
53 | 53 | return $this->getSerialiser()->serialize($this->getEdmx(), "xml"); |
54 | 54 | } |
55 | 55 | |
56 | + /** |
|
57 | + * @param string $name |
|
58 | + * @param TTextType $summary |
|
59 | + * @param TTextType $longDescription |
|
60 | + */ |
|
56 | 61 | public function addEntityType($name, $accessType = "Public", $summary = null, $longDescription = null) |
57 | 62 | { |
58 | 63 | $NewEntity = new TEntityTypeType(); |
@@ -126,6 +131,14 @@ discard block |
||
126 | 131 | return $NewProperty; |
127 | 132 | } |
128 | 133 | |
134 | + /** |
|
135 | + * @param string $name |
|
136 | + * @param string $type |
|
137 | + * @param string $defaultValue |
|
138 | + * @param string $storeGeneratedPattern |
|
139 | + * @param TTextType $summary |
|
140 | + * @param TTextType $longDescription |
|
141 | + */ |
|
129 | 142 | public function addPropertyToEntityType( |
130 | 143 | TEntityTypeType $entityType, |
131 | 144 | $name, |
@@ -158,6 +171,11 @@ discard block |
||
158 | 171 | return $NewProperty; |
159 | 172 | } |
160 | 173 | |
174 | + /** |
|
175 | + * @param string $principalMultiplicity |
|
176 | + * @param string $principalProperty |
|
177 | + * @param string $dependentMultiplicity |
|
178 | + */ |
|
161 | 179 | public function addNavigationPropertyToEntityType( |
162 | 180 | TEntityTypeType $principalType, |
163 | 181 | $principalMultiplicity, |
@@ -320,6 +338,10 @@ discard block |
||
320 | 338 | return $association; |
321 | 339 | } |
322 | 340 | |
341 | + /** |
|
342 | + * @param string $principalEntitySetName |
|
343 | + * @param string $dependentEntitySetName |
|
344 | + */ |
|
323 | 345 | protected function createAssocationSetForAssocation( |
324 | 346 | TAssociationType $association, |
325 | 347 | $principalEntitySetName, |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $entitySet = new EntitySetAnonymousType(); |
66 | 66 | $entitySet->setName(Str::plural($NewEntity->getName())); |
67 | 67 | $namespace = $this->getNamespace(); |
68 | - $entityTypeName = $namespace . $NewEntity->getName(); |
|
68 | + $entityTypeName = $namespace.$NewEntity->getName(); |
|
69 | 69 | $entitySet->setEntityType($entityTypeName); |
70 | 70 | $entitySet->setGetterAccess($accessType); |
71 | 71 | |
@@ -178,17 +178,17 @@ discard block |
||
178 | 178 | ) { |
179 | 179 | $principalEntitySetName = Str::plural($principalType->getName()); |
180 | 180 | $dependentEntitySetName = Str::plural($dependentType->getName()); |
181 | - $relationName = $principalType->getName() . "_" . $principalProperty . "_" |
|
182 | - . $dependentType->getName() . "_" . $dependentProperty; |
|
181 | + $relationName = $principalType->getName()."_".$principalProperty."_" |
|
182 | + . $dependentType->getName()."_".$dependentProperty; |
|
183 | 183 | $relationName = trim($relationName, "_"); |
184 | 184 | |
185 | 185 | $namespace = $this->getNamespace(); |
186 | - $relationFQName = $namespace . $relationName; |
|
186 | + $relationFQName = $namespace.$relationName; |
|
187 | 187 | |
188 | 188 | $principalNavigationProperty = new TNavigationPropertyType(); |
189 | 189 | $principalNavigationProperty->setName($principalProperty); |
190 | - $principalNavigationProperty->setToRole(trim($dependentEntitySetName . "_" . $dependentProperty, "_")); |
|
191 | - $principalNavigationProperty->setFromRole($principalEntitySetName . "_" . $principalProperty); |
|
190 | + $principalNavigationProperty->setToRole(trim($dependentEntitySetName."_".$dependentProperty, "_")); |
|
191 | + $principalNavigationProperty->setFromRole($principalEntitySetName."_".$principalProperty); |
|
192 | 192 | $principalNavigationProperty->setRelationship($relationFQName); |
193 | 193 | $principalNavigationProperty->setGetterAccess($principalGetterAccess); |
194 | 194 | $principalNavigationProperty->setSetterAccess($principalSetterAccess); |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | if (!empty($dependentProperty)) { |
202 | 202 | $dependentNavigationProperty = new TNavigationPropertyType(); |
203 | 203 | $dependentNavigationProperty->setName($dependentProperty); |
204 | - $dependentNavigationProperty->setToRole($principalEntitySetName . "_" . $principalProperty); |
|
205 | - $dependentNavigationProperty->setFromRole($dependentEntitySetName . "_" . $dependentProperty); |
|
204 | + $dependentNavigationProperty->setToRole($principalEntitySetName."_".$principalProperty); |
|
205 | + $dependentNavigationProperty->setFromRole($dependentEntitySetName."_".$dependentProperty); |
|
206 | 206 | $dependentNavigationProperty->setRelationship($relationFQName); |
207 | 207 | $dependentNavigationProperty->setGetterAccess($dependentGetterAccess); |
208 | 208 | $dependentNavigationProperty->setSetterAccess($dependentSetterAccess); |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | array $principalConstraintProperty = null, |
250 | 250 | array $dependentConstraintProperty = null |
251 | 251 | ) { |
252 | - $multCombo = [ '*' => ['*', '1'], '0..1' => ['1'], '1' => ['*', '0..1']]; |
|
252 | + $multCombo = ['*' => ['*', '1'], '0..1' => ['1'], '1' => ['*', '0..1']]; |
|
253 | 253 | $multKeys = array_keys($multCombo); |
254 | 254 | if (null != $dependentNavigationProperty) { |
255 | 255 | if ($dependentNavigationProperty->getRelationship() != $principalNavigationProperty->getRelationship()) { |
@@ -270,13 +270,13 @@ discard block |
||
270 | 270 | } |
271 | 271 | if (!in_array($dependentMultiplicity, $multCombo[$principalMultiplicity])) { |
272 | 272 | throw new \InvalidArgumentException( |
273 | - "Invalid multiplicity combination - ". $principalMultiplicity . ' ' . $dependentMultiplicity |
|
273 | + "Invalid multiplicity combination - ".$principalMultiplicity.' '.$dependentMultiplicity |
|
274 | 274 | ); |
275 | 275 | } |
276 | 276 | |
277 | 277 | $namespace = $this->getNamespace(); |
278 | - $principalTypeFQName = $namespace . $principalType->getName(); |
|
279 | - $dependentTypeFQName = $namespace . $dependentType->getName(); |
|
278 | + $principalTypeFQName = $namespace.$principalType->getName(); |
|
279 | + $dependentTypeFQName = $namespace.$dependentType->getName(); |
|
280 | 280 | $association = new TAssociationType(); |
281 | 281 | $relationship = $principalNavigationProperty->getRelationship(); |
282 | 282 | if (false !== strpos($relationship, '.')) { |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | $name = $association->getName(); |
330 | 330 | $as->setName($name); |
331 | 331 | $namespace = $this->getNamespace(); |
332 | - $associationSetName = $namespace . $association->getName(); |
|
332 | + $associationSetName = $namespace.$association->getName(); |
|
333 | 333 | $as->setAssociation($associationSetName); |
334 | 334 | $end1 = new EndAnonymousType(); |
335 | 335 | $end1->setRole($association->getEnd()[0]->getRole()); |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | |
393 | 393 | private function initSerialiser() |
394 | 394 | { |
395 | - $ymlDir = __DIR__ . DIRECTORY_SEPARATOR . "MetadataV3" . DIRECTORY_SEPARATOR . "JMSmetadata"; |
|
395 | + $ymlDir = __DIR__.DIRECTORY_SEPARATOR."MetadataV3".DIRECTORY_SEPARATOR."JMSmetadata"; |
|
396 | 396 | $this->serializer = |
397 | 397 | SerializerBuilder::create() |
398 | 398 | ->addMetadataDir($ymlDir) |
@@ -11,8 +11,6 @@ |
||
11 | 11 | use AlgoWeb\ODataMetadata\MetadataV3\edm\TComplexTypeType; |
12 | 12 | use AlgoWeb\ODataMetadata\MetadataV3\edm\TEntityPropertyType; |
13 | 13 | use AlgoWeb\ODataMetadata\MetadataV3\edm\TEntityTypeType; |
14 | -use AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionReturnTypeType; |
|
15 | -use AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionType; |
|
16 | 14 | use AlgoWeb\ODataMetadata\MetadataV3\edm\TNavigationPropertyType; |
17 | 15 | use AlgoWeb\ODataMetadata\MetadataV3\edm\TTextType; |
18 | 16 | use AlgoWeb\ODataMetadata\MetadataV3\edmx\Edmx; |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | { |
38 | 38 | $ds = DIRECTORY_SEPARATOR; |
39 | 39 | |
40 | - $goodxsd = dirname(__DIR__) . $ds . "xsd" . $ds . "Microsoft.Data.Entity.Design.Edmx_3.Fixed.xsd"; |
|
40 | + $goodxsd = dirname(__DIR__).$ds."xsd".$ds."Microsoft.Data.Entity.Design.Edmx_3.Fixed.xsd"; |
|
41 | 41 | if (!file_exists($goodxsd)) { |
42 | 42 | return true; |
43 | 43 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $result = null; |
53 | 53 | |
54 | 54 | list($eType, $result) = $metadataManager->addEntityType("Category"); |
55 | - $this->assertNotFalse($eType, "Etype is false not type " . $metadataManager->getLastError()); |
|
55 | + $this->assertNotFalse($eType, "Etype is false not type ".$metadataManager->getLastError()); |
|
56 | 56 | $metadataManager->addPropertyToEntityType($eType, "CategoryID", "Int32", null, false, true, "Identity"); |
57 | 57 | $metadataManager->addPropertyToEntityType($eType, "CategoryName", "String"); |
58 | 58 | $metadataManager->addPropertyToEntityType($eType, "Description", "String"); |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | $result = null; |
80 | 80 | |
81 | 81 | list($CategoryType, $result) = $metadataManager->addEntityType("Category"); |
82 | - $this->assertNotFalse($CategoryType, "Etype is false not type " . $metadataManager->getLastError()); |
|
82 | + $this->assertNotFalse($CategoryType, "Etype is false not type ".$metadataManager->getLastError()); |
|
83 | 83 | $metadataManager->addPropertyToEntityType($CategoryType, "CategoryID", "Int32", null, false, true, "Identity"); |
84 | 84 | $metadataManager->addPropertyToEntityType($CategoryType, "CategoryName", "String"); |
85 | 85 | $metadataManager->addPropertyToEntityType($CategoryType, "Description", "String"); |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | $this->assertTrue($metadataManager->getEdmx()->isOK($msg), $msg); |
166 | 166 | |
167 | 167 | $expectedRelation = "Data.Category_Products_Product_Category"; |
168 | - list($principalNav, ) = $metadataManager->addNavigationPropertyToEntityType( |
|
168 | + list($principalNav,) = $metadataManager->addNavigationPropertyToEntityType( |
|
169 | 169 | $CategoryType, "*", "Products", $ProductType, "1", "Category", ["CategoryID"], ["CategoryID"] |
170 | 170 | ); |
171 | 171 | $this->assertEquals($expectedRelation, $principalNav->getRelationship()); |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | { |
611 | 611 | list(, $metadataManager, $CategoryType, $CustomerType) = $this->setUpMetadataForNavTests(); |
612 | 612 | |
613 | - $expected = "Invalid multiplicity combination - 1 1"; |
|
613 | + $expected = "Invalid multiplicity combination - 1 1"; |
|
614 | 614 | $actual = null; |
615 | 615 | |
616 | 616 | try { |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | { |
633 | 633 | list(, $metadataManager, $CategoryType, $CustomerType) = $this->setUpMetadataForNavTests(); |
634 | 634 | |
635 | - $expected = "Invalid multiplicity combination - * 0..1"; |
|
635 | + $expected = "Invalid multiplicity combination - * 0..1"; |
|
636 | 636 | $actual = null; |
637 | 637 | |
638 | 638 | try { |
@@ -652,7 +652,7 @@ discard block |
||
652 | 652 | |
653 | 653 | public function testAddComplexType() |
654 | 654 | { |
655 | - list(, $metadataManager, , ) = $this->setUpMetadataForNavTests(); |
|
655 | + list(, $metadataManager,,) = $this->setUpMetadataForNavTests(); |
|
656 | 656 | |
657 | 657 | $name = "Name"; |
658 | 658 | $accessType = "Public"; |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | $result = $metadataManager->addComplexType($name, $accessType, $summary, $longDescription); |
665 | 665 | |
666 | 666 | $newCount = count($metadataManager->getEdmx()->getDataServiceType()->getSchema()[0]->getComplexType()); |
667 | - $this->assertEquals($oldCount+1, $newCount); |
|
667 | + $this->assertEquals($oldCount + 1, $newCount); |
|
668 | 668 | $this->assertNotNull($result); |
669 | 669 | $this->assertTrue($result instanceof TComplexTypeType, get_class($result)); |
670 | 670 | $this->assertNotNull($result->getDocumentation()); |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | |
673 | 673 | public function testAddComplexTypeWithOnlySummary() |
674 | 674 | { |
675 | - list(, $metadataManager, , ) = $this->setUpMetadataForNavTests(); |
|
675 | + list(, $metadataManager,,) = $this->setUpMetadataForNavTests(); |
|
676 | 676 | |
677 | 677 | $name = "Name"; |
678 | 678 | $accessType = "Public"; |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | $result = $metadataManager->addComplexType($name, $accessType, $summary, $longDescription); |
685 | 685 | |
686 | 686 | $newCount = count($metadataManager->getEdmx()->getDataServiceType()->getSchema()[0]->getComplexType()); |
687 | - $this->assertEquals($oldCount+1, $newCount); |
|
687 | + $this->assertEquals($oldCount + 1, $newCount); |
|
688 | 688 | $this->assertNotNull($result); |
689 | 689 | $this->assertTrue($result instanceof TComplexTypeType, get_class($result)); |
690 | 690 | $this->assertNull($result->getDocumentation()); |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | |
693 | 693 | public function testAddComplexTypeWithOnlyDescription() |
694 | 694 | { |
695 | - list(, $metadataManager, , ) = $this->setUpMetadataForNavTests(); |
|
695 | + list(, $metadataManager,,) = $this->setUpMetadataForNavTests(); |
|
696 | 696 | |
697 | 697 | $name = "Name"; |
698 | 698 | $accessType = "Public"; |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | $result = $metadataManager->addComplexType($name, $accessType, $summary, $longDescription); |
705 | 705 | |
706 | 706 | $newCount = count($metadataManager->getEdmx()->getDataServiceType()->getSchema()[0]->getComplexType()); |
707 | - $this->assertEquals($oldCount+1, $newCount); |
|
707 | + $this->assertEquals($oldCount + 1, $newCount); |
|
708 | 708 | $this->assertNotNull($result); |
709 | 709 | $this->assertTrue($result instanceof TComplexTypeType, get_class($result)); |
710 | 710 | $this->assertNull($result->getDocumentation()); |
@@ -715,7 +715,7 @@ discard block |
||
715 | 715 | $expected = "Default value cannot be object or array"; |
716 | 716 | $actual = null; |
717 | 717 | |
718 | - list(, $metadataManager, , ) = $this->setUpMetadataForNavTests(); |
|
718 | + list(, $metadataManager,,) = $this->setUpMetadataForNavTests(); |
|
719 | 719 | $complex = m::mock(TComplexTypeType::class); |
720 | 720 | $name = "name"; |
721 | 721 | $type = "type"; |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | $expected = "Default value cannot be object or array"; |
735 | 735 | $actual = null; |
736 | 736 | |
737 | - list(, $metadataManager, , ) = $this->setUpMetadataForNavTests(); |
|
737 | + list(, $metadataManager,,) = $this->setUpMetadataForNavTests(); |
|
738 | 738 | $complex = m::mock(TComplexTypeType::class); |
739 | 739 | $name = "name"; |
740 | 740 | $type = "type"; |
@@ -750,7 +750,7 @@ discard block |
||
750 | 750 | |
751 | 751 | public function testAddPropertyToComplexTypeDefaultValueBoolean() |
752 | 752 | { |
753 | - list(, $metadataManager, , ) = $this->setUpMetadataForNavTests(); |
|
753 | + list(, $metadataManager,,) = $this->setUpMetadataForNavTests(); |
|
754 | 754 | $complex = m::mock(TComplexTypeType::class); |
755 | 755 | $complex->shouldReceive('addToProperty') |
756 | 756 | ->with(m::type(TComplexTypePropertyType::class))->andReturnNull()->once(); |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | |
777 | 777 | public function testAddPropertyToComplexTypeDefaultValueBooleanOnlySummary() |
778 | 778 | { |
779 | - list(, $metadataManager, , ) = $this->setUpMetadataForNavTests(); |
|
779 | + list(, $metadataManager,,) = $this->setUpMetadataForNavTests(); |
|
780 | 780 | $complex = m::mock(TComplexTypeType::class); |
781 | 781 | $complex->shouldReceive('addToProperty') |
782 | 782 | ->with(m::type(TComplexTypePropertyType::class))->andReturnNull()->once(); |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | |
804 | 804 | public function testAddPropertyToComplexTypeDefaultValueBooleanOnlyDescription() |
805 | 805 | { |
806 | - list(, $metadataManager, , ) = $this->setUpMetadataForNavTests(); |
|
806 | + list(, $metadataManager,,) = $this->setUpMetadataForNavTests(); |
|
807 | 807 | $complex = m::mock(TComplexTypeType::class); |
808 | 808 | $complex->shouldReceive('addToProperty') |
809 | 809 | ->with(m::type(TComplexTypePropertyType::class))->andReturnNull()->once(); |
@@ -922,7 +922,7 @@ discard block |
||
922 | 922 | $longDescription = new TTextType(); |
923 | 923 | |
924 | 924 | $metadataManager = new MetadataManager(); |
925 | - list($result, ) = $metadataManager->addEntityType($name, $accessType, $summary, $longDescription); |
|
925 | + list($result,) = $metadataManager->addEntityType($name, $accessType, $summary, $longDescription); |
|
926 | 926 | $this->assertNotNull($result->getDocumentation()); |
927 | 927 | } |
928 | 928 | |
@@ -934,7 +934,7 @@ discard block |
||
934 | 934 | $longDescription = null; |
935 | 935 | |
936 | 936 | $metadataManager = new MetadataManager(); |
937 | - list($result, ) = $metadataManager->addEntityType($name, $accessType, $summary, $longDescription); |
|
937 | + list($result,) = $metadataManager->addEntityType($name, $accessType, $summary, $longDescription); |
|
938 | 938 | $this->assertNull($result->getDocumentation()); |
939 | 939 | } |
940 | 940 | |
@@ -946,7 +946,7 @@ discard block |
||
946 | 946 | $longDescription = new TTextType(); |
947 | 947 | |
948 | 948 | $metadataManager = new MetadataManager(); |
949 | - list($result, ) = $metadataManager->addEntityType($name, $accessType, $summary, $longDescription); |
|
949 | + list($result,) = $metadataManager->addEntityType($name, $accessType, $summary, $longDescription); |
|
950 | 950 | $this->assertNull($result->getDocumentation()); |
951 | 951 | } |
952 | 952 |