Conditions | 1 |
Paths | 1 |
Total Lines | 59 |
Code Lines | 29 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
45 | public function testBase() |
||
46 | { |
||
47 | $schema = $this->reader->readString(' |
||
48 | <xs:schema targetNamespace="http://www.example.com" xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
||
49 | |||
50 | <xs:simpleType name="mySimple"> |
||
51 | <xs:restriction base="xs:string"></xs:restriction> |
||
52 | </xs:simpleType> |
||
53 | |||
54 | <xs:simpleType name="mySimpleWithRestr"> |
||
55 | <xs:restriction base="mySimple"></xs:restriction> |
||
56 | </xs:simpleType> |
||
57 | |||
58 | <xs:complexType name="myComplex"> |
||
59 | <xs:simpleContent> |
||
60 | <xs:extension base="mySimpleWithRestr"></xs:extension> |
||
61 | </xs:simpleContent> |
||
62 | </xs:complexType> |
||
63 | |||
64 | <xs:simpleType name="mySimpleWithUnion"> |
||
65 | <xs:union memberTypes="xs:string mySimpleWithRestr"></xs:union> |
||
66 | </xs:simpleType> |
||
67 | |||
68 | </xs:schema>'); |
||
69 | |||
70 | $this->assertCount(4, $schema->getTypes()); |
||
71 | $this->assertInstanceOf('GoetasWebservices\XML\XSDReader\Schema\Type\SimpleType', $type = $schema->findType('mySimple', 'http://www.example.com')); |
||
72 | $this->assertInstanceOf('GoetasWebservices\XML\XSDReader\Schema\Type\SimpleType', $type2 = $schema->findType('mySimpleWithRestr', 'http://www.example.com')); |
||
73 | $this->assertInstanceOf('GoetasWebservices\XML\XSDReader\Schema\Type\ComplexTypeSimpleContent', $type3 = $schema->findType('myComplex', 'http://www.example.com')); |
||
74 | $this->assertInstanceOf('GoetasWebservices\XML\XSDReader\Schema\Type\SimpleType', $type4 = $schema->findType('mySimpleWithUnion', 'http://www.example.com')); |
||
75 | |||
76 | $restriction1 = $type->getRestriction(); |
||
77 | $base1 = $restriction1->getBase(); |
||
78 | $this->assertInstanceOf('GoetasWebservices\XML\XSDReader\Schema\Type\SimpleType', $base1); |
||
79 | $this->assertEquals('http://www.w3.org/2001/XMLSchema', $base1->getSchema()->getTargetNamespace()); |
||
80 | $this->assertEquals('string', $base1->getName()); |
||
81 | |||
82 | $restriction2 = $type2->getRestriction(); |
||
83 | $base2 = $restriction2->getBase(); |
||
84 | $this->assertInstanceOf('GoetasWebservices\XML\XSDReader\Schema\Type\SimpleType', $base2); |
||
85 | $this->assertEquals('http://www.example.com', $base2->getSchema()->getTargetNamespace()); |
||
86 | $this->assertEquals('mySimple', $base2->getName()); |
||
87 | |||
88 | $extension = $type3->getExtension(); |
||
89 | $base3 = $extension->getBase(); |
||
90 | $this->assertInstanceOf('GoetasWebservices\XML\XSDReader\Schema\Type\SimpleType', $base3); |
||
91 | $this->assertEquals('http://www.example.com', $base3->getSchema()->getTargetNamespace()); |
||
92 | $this->assertEquals('mySimpleWithRestr', $base3->getName()); |
||
93 | |||
94 | $unions = $type4->getUnions(); |
||
95 | $this->assertCount(2, $unions); |
||
96 | $this->assertInstanceOf('GoetasWebservices\XML\XSDReader\Schema\Type\SimpleType', $unions[0]); |
||
97 | $this->assertInstanceOf('GoetasWebservices\XML\XSDReader\Schema\Type\SimpleType', $unions[1]); |
||
98 | |||
99 | $this->assertEquals('http://www.w3.org/2001/XMLSchema', $unions[0]->getSchema()->getTargetNamespace()); |
||
100 | $this->assertEquals('string', $unions[0]->getName()); |
||
101 | |||
102 | $this->assertEquals('http://www.example.com', $unions[1]->getSchema()->getTargetNamespace()); |
||
103 | $this->assertEquals('mySimpleWithRestr', $unions[1]->getName()); |
||
104 | } |
||
189 |