Conditions | 1 |
Paths | 1 |
Total Lines | 53 |
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 |
||
13 | public function testRelation() |
||
14 | { |
||
15 | $xml = <<< XML |
||
16 | <?xml version="1.0" encoding="UTF-8"?> |
||
17 | <ContentCreate> |
||
18 | <ContentType href="/api/ezp/v2/content/types/2" /> |
||
19 | <mainLanguageCode>eng-GB</mainLanguageCode> |
||
20 | <LocationCreate> |
||
21 | <ParentLocation href="/api/ezp/v2/content/locations/1/2" /> |
||
22 | <priority>0</priority> |
||
23 | <hidden>false</hidden> |
||
24 | <sortField>PATH</sortField> |
||
25 | <sortOrder>ASC</sortOrder> |
||
26 | </LocationCreate> |
||
27 | <Section href="/api/ezp/v2/content/sections/1" /> |
||
28 | <alwaysAvailable>true</alwaysAvailable> |
||
29 | <User href="/api/ezp/v2/user/users/14" /> |
||
30 | <modificationDate>2012-09-30T12:30:00</modificationDate> |
||
31 | <fields> |
||
32 | <field> |
||
33 | <fieldDefinitionIdentifier>title</fieldDefinitionIdentifier> |
||
34 | <languageCode>eng-GB</languageCode> |
||
35 | <fieldValue>testRelation</fieldValue> |
||
36 | </field> |
||
37 | <field> |
||
38 | <fieldDefinitionIdentifier>intro</fieldDefinitionIdentifier> |
||
39 | <languageCode>eng-GB</languageCode> |
||
40 | <fieldValue> |
||
41 | <value key="xml"><?xml version="1.0" encoding="UTF-8"?> |
||
42 | <section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ezxhtml="http://ez.no/xmlns/ezpublish/docbook/xhtml" xmlns:ezcustom="http://ez.no/xmlns/ezpublish/docbook/custom" version="5.0-variant ezpublish-1.0"> |
||
43 | <title ezxhtml:level="2">This is a title.</title> |
||
44 | <para><link xlink:href="ezcontent://1" xml:id="id1" xlink:title="Content title" ezxhtml:class="linkClass5">Content name</link></para> |
||
45 | <ezembed xlink:href="ezcontent://1" view="line" xml:id="embed-id-2" ezxhtml:class="embedClass2" ezxhtml:align="right"/> |
||
46 | </section></value> |
||
47 | </fieldValue> |
||
48 | </field> |
||
49 | <field> |
||
50 | <fieldDefinitionIdentifier>image</fieldDefinitionIdentifier> |
||
51 | <languageCode>eng-GB</languageCode> |
||
52 | <fieldValue> |
||
53 | <value key="destinationContentId">1</value> |
||
54 | </fieldValue> |
||
55 | </field> |
||
56 | </fields> |
||
57 | </ContentCreate> |
||
58 | XML; |
||
59 | $testContent = $this->createContent($xml); |
||
60 | $relations = $testContent['CurrentVersion']['Version']['Relations']['Relation']; |
||
61 | |||
62 | self::assertEquals('LINK', $relations[0]['RelationType']); |
||
63 | self::assertEquals('EMBED', $relations[1]['RelationType']); |
||
64 | self::assertEquals('ATTRIBUTE', $relations[2]['RelationType']); |
||
65 | } |
||
66 | } |
||
67 |