Completed
Pull Request — master (#107)
by Alex
05:30
created
src/MetadataManager.php 3 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -15,8 +15,6 @@
 block discarded – undo
15 15
 use AlgoWeb\ODataMetadata\MetadataV3\edm\TEntityPropertyType;
16 16
 use AlgoWeb\ODataMetadata\MetadataV3\edm\TEntityTypeType;
17 17
 use AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionImportReturnTypeType;
18
-use AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionReturnTypeType;
19
-use AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionType;
20 18
 use AlgoWeb\ODataMetadata\MetadataV3\edm\TNavigationPropertyType;
21 19
 use AlgoWeb\ODataMetadata\MetadataV3\edm\TPropertyRefType;
22 20
 use AlgoWeb\ODataMetadata\MetadataV3\edm\TReferentialConstraintRoleElementType;
Please login to merge, or discard this patch.
Doc Comments   +22 added lines patch added patch discarded remove patch
@@ -54,6 +54,11 @@  discard block
 block discarded – undo
54 54
         return $cereal->serialize($this->getEdmx(), "xml");
55 55
     }
56 56
 
57
+    /**
58
+     * @param string $name
59
+     * @param TTextType $summary
60
+     * @param TTextType $longDescription
61
+     */
57 62
     public function addEntityType($name, $accessType = "Public", $summary = null, $longDescription = null)
58 63
     {
59 64
         $NewEntity = new TEntityTypeType();
@@ -118,6 +123,14 @@  discard block
 block discarded – undo
118 123
         return $NewProperty;
119 124
     }
120 125
 
126
+    /**
127
+     * @param string $name
128
+     * @param string $type
129
+     * @param string $defaultValue
130
+     * @param string $storeGeneratedPattern
131
+     * @param TTextType $summary
132
+     * @param TTextType $longDescription
133
+     */
121 134
     public function addPropertyToEntityType(
122 135
         TEntityTypeType $entityType,
123 136
         $name,
@@ -147,6 +160,11 @@  discard block
 block discarded – undo
147 160
         return $NewProperty;
148 161
     }
149 162
 
163
+    /**
164
+     * @param string $principalMultiplicity
165
+     * @param string $principalProperty
166
+     * @param string $dependentMultiplicity
167
+     */
150 168
     public function addNavigationPropertyToEntityType(
151 169
         TEntityTypeType $principalType,
152 170
         $principalMultiplicity,
@@ -301,6 +319,10 @@  discard block
 block discarded – undo
301 319
         return $association;
302 320
     }
303 321
 
322
+    /**
323
+     * @param string $principalEntitySetName
324
+     * @param string $dependentEntitySetName
325
+     */
304 326
     protected function createAssocationSetForAssocation(
305 327
         TAssociationType $association,
306 328
         $principalEntitySetName,
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         $entitySet = new EntitySetAnonymousType();
64 64
         $entitySet->setName(Str::plural($NewEntity->getName()));
65 65
         $namespace = $this->getNamespace();
66
-        $entityTypeName = $namespace . $NewEntity->getName();
66
+        $entityTypeName = $namespace.$NewEntity->getName();
67 67
         $entitySet->setEntityType($entityTypeName);
68 68
         $entitySet->setGetterAccess($accessType);
69 69
 
@@ -167,17 +167,17 @@  discard block
 block discarded – undo
167 167
     ) {
168 168
         $principalEntitySetName = Str::plural($principalType->getName());
169 169
         $dependentEntitySetName = Str::plural($dependentType->getName());
170
-        $relationName = $principalType->getName() . "_" . $principalProperty . "_"
171
-                        . $dependentType->getName() . "_" . $dependentProperty;
170
+        $relationName = $principalType->getName()."_".$principalProperty."_"
171
+                        . $dependentType->getName()."_".$dependentProperty;
172 172
         $relationName = trim($relationName, "_");
173 173
 
174 174
         $namespace = $this->getNamespace();
175
-        $relationFQName = $namespace . $relationName;
175
+        $relationFQName = $namespace.$relationName;
176 176
 
177 177
         $principalNavigationProperty = new TNavigationPropertyType();
178 178
         $principalNavigationProperty->setName($principalProperty);
179
-        $principalNavigationProperty->setToRole(trim($dependentEntitySetName . "_" . $dependentProperty, "_"));
180
-        $principalNavigationProperty->setFromRole($principalEntitySetName . "_" . $principalProperty);
179
+        $principalNavigationProperty->setToRole(trim($dependentEntitySetName."_".$dependentProperty, "_"));
180
+        $principalNavigationProperty->setFromRole($principalEntitySetName."_".$principalProperty);
181 181
         $principalNavigationProperty->setRelationship($relationFQName);
182 182
         $principalNavigationProperty->setGetterAccess($principalGetterAccess);
183 183
         $principalNavigationProperty->setSetterAccess($principalSetterAccess);
@@ -187,8 +187,8 @@  discard block
 block discarded – undo
187 187
         if (!empty($dependentProperty)) {
188 188
             $dependentNavigationProperty = new TNavigationPropertyType();
189 189
             $dependentNavigationProperty->setName($dependentProperty);
190
-            $dependentNavigationProperty->setToRole($principalEntitySetName . "_" . $principalProperty);
191
-            $dependentNavigationProperty->setFromRole($dependentEntitySetName . "_" . $dependentProperty);
190
+            $dependentNavigationProperty->setToRole($principalEntitySetName."_".$principalProperty);
191
+            $dependentNavigationProperty->setFromRole($dependentEntitySetName."_".$dependentProperty);
192 192
             $dependentNavigationProperty->setRelationship($relationFQName);
193 193
             $dependentNavigationProperty->setGetterAccess($dependentGetterAccess);
194 194
             $dependentNavigationProperty->setSetterAccess($dependentSetterAccess);
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
         array $principalConstraintProperty = null,
233 233
         array $dependentConstraintProperty = null
234 234
     ) {
235
-        $multCombo = [ '*' => ['*', '1'], '0..1' => ['1'], '1' => ['*', '0..1']];
235
+        $multCombo = ['*' => ['*', '1'], '0..1' => ['1'], '1' => ['*', '0..1']];
236 236
         $multKeys = array_keys($multCombo);
237 237
         if (null != $dependentNavigationProperty) {
238 238
             if ($dependentNavigationProperty->getRelationship() != $principalNavigationProperty->getRelationship()) {
@@ -253,13 +253,13 @@  discard block
 block discarded – undo
253 253
         }
254 254
         if (!in_array($dependentMultiplicity, $multCombo[$principalMultiplicity])) {
255 255
             throw new \InvalidArgumentException(
256
-                "Invalid multiplicity combination - ". $principalMultiplicity . ' ' . $dependentMultiplicity
256
+                "Invalid multiplicity combination - ".$principalMultiplicity.' '.$dependentMultiplicity
257 257
             );
258 258
         }
259 259
 
260 260
         $namespace = $this->getNamespace();
261
-        $principalTypeFQName = $namespace . $principalType->getName();
262
-        $dependentTypeFQName = $namespace . $dependentType->getName();
261
+        $principalTypeFQName = $namespace.$principalType->getName();
262
+        $dependentTypeFQName = $namespace.$dependentType->getName();
263 263
         $association = new TAssociationType();
264 264
         $relationship = $principalNavigationProperty->getRelationship();
265 265
         if (false !== strpos($relationship, '.')) {
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
         $name = $association->getName();
311 311
         $as->setName($name);
312 312
         $namespace = $this->getNamespace();
313
-        $associationSetName = $namespace . $association->getName();
313
+        $associationSetName = $namespace.$association->getName();
314 314
         $as->setAssociation($associationSetName);
315 315
         $end1 = new EndAnonymousType();
316 316
         $end1->setRole($association->getEnd()[0]->getRole());
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 
371 371
     private function initSerialiser()
372 372
     {
373
-        $ymlDir = __DIR__ . DIRECTORY_SEPARATOR . "MetadataV3" . DIRECTORY_SEPARATOR . "JMSmetadata";
373
+        $ymlDir = __DIR__.DIRECTORY_SEPARATOR."MetadataV3".DIRECTORY_SEPARATOR."JMSmetadata";
374 374
         $this->serializer =
375 375
             SerializerBuilder::create()
376 376
                 ->addMetadataDir($ymlDir)
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
      * @param $longDescription
441 441
      * @param $NewEntity
442 442
      */
443
-    private function addDocumentation($summary, $longDescription, IsOK &$NewEntity)
443
+    private function addDocumentation($summary, $longDescription, IsOK & $NewEntity)
444 444
     {
445 445
         if (null != $summary && null != $longDescription) {
446 446
             $documentation = $this->generateDocumentation($summary, $longDescription);
Please login to merge, or discard this patch.
src/MetadataV3/edm/EntityContainer/FunctionImportAnonymousType.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@
 block discarded – undo
138 138
         }
139 139
 
140 140
         $numParms = count($this->parameter);
141
-        for ($i = 0; $i < $numParms -2; $i++) {
141
+        for ($i = 0; $i < $numParms - 2; $i++) {
142 142
             $outName = $this->parameter[$i]->getName();
143 143
             for ($j = $i + 1; $j < $numParms - 1; $j++) {
144 144
                 $inName = $this->parameter[$j]->getName();
Please login to merge, or discard this patch.
src/MetadataV3/edm/TFunctionType.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -308,7 +308,7 @@
 block discarded – undo
308 308
         }
309 309
         foreach ($this->returnType as $type) {
310 310
             if (!is_string($type) || !$this->isTCommandTextValid($type)) {
311
-                $msg = implode($type) . " must be a valid TCommandText";
311
+                $msg = implode($type)." must be a valid TCommandText";
312 312
                 return false;
313 313
             }
314 314
         }
Please login to merge, or discard this patch.
tests/MetadataManagerTest.php 2 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -11,8 +11,6 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/MetadataV3/edm/Groups/TFunctionImportAttributesTrait.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
     /**
94 94
      * isset returnType
95 95
      *
96
-     * @param scalar $index
96
+     * @param integer $index
97 97
      * @return boolean
98 98
      */
99 99
     public function issetReturnType($index)
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
     /**
105 105
      * unset returnType
106 106
      *
107
-     * @param scalar $index
107
+     * @param integer $index
108 108
      * @return void
109 109
      */
110 110
     public function unsetReturnType($index)
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
     public function isTFunctionImportAttributesValid(&$msg)
266 266
     {
267 267
         if (!$this->isTSimpleIdentifierValid($this->name)) {
268
-            $msg = "Name must be a valid TSimpleIdentifier: " . get_class($this);
268
+            $msg = "Name must be a valid TSimpleIdentifier: ".get_class($this);
269 269
             return false;
270 270
         }
271 271
         if ($this->isComposable && $this->isSideEffecting) {
@@ -278,11 +278,11 @@  discard block
 block discarded – undo
278 278
             return false;
279 279
         }*/
280 280
         if (!$this->isObjectNullOrType('\AlgoWeb\ODataMetadata\MetadataV3\edm\TOperandType', $this->entitySet)) {
281
-            $msg = "Entity set must be either null or an instance of TOperandType: " . get_class($this);
281
+            $msg = "Entity set must be either null or an instance of TOperandType: ".get_class($this);
282 282
             return false;
283 283
         }
284 284
         if (null != $this->methodAccess && !$this->isTAccessOk($this->methodAccess)) {
285
-            $msg = "Method access must be a valid TAccess: " . get_class($this);
285
+            $msg = "Method access must be a valid TAccess: ".get_class($this);
286 286
             return false;
287 287
         }
288 288
         if (!$this->isValidArrayOK(
Please login to merge, or discard this patch.