Conditions | 1 |
Paths | 1 |
Total Lines | 87 |
Code Lines | 65 |
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 |
||
32 | public function validProvider() { |
||
33 | $item = new Item( |
||
34 | new ItemId('Q42'), |
||
35 | null, |
||
36 | new SiteLinkList(array(new SiteLink('enwiki', 'Douglas Adams'))) |
||
37 | ); |
||
38 | |||
39 | return array( |
||
40 | array( |
||
41 | $item, |
||
42 | (object) array( |
||
43 | '@type' => 'Thing', |
||
44 | '@id' => 'http://www.wikidata.org/entity/Q42', |
||
45 | 'name' => 'Q42', |
||
46 | 'potentialAction' => array( |
||
47 | (object) array( |
||
48 | '@type' => 'ViewAction', |
||
49 | 'name' => array( |
||
50 | (object) array('@value' => 'View on Wikidata', '@language' => 'en'), |
||
51 | (object) array('@value' => 'Voir sur Wikidata', '@language' => 'fr') |
||
52 | ), |
||
53 | 'image' => '//upload.wikimedia.org/wikipedia/commons/f/ff/Wikidata-logo.svg', |
||
54 | 'target' => '//www.wikidata.org/entity/Q42' |
||
55 | ), |
||
56 | (object) array( |
||
57 | '@type' => 'ViewAction', |
||
58 | 'name' => array( |
||
59 | (object) array('@value' => 'View on Wikipedia', '@language' => 'en'), |
||
60 | (object) array('@value' => 'Voir sur Wikipédia', '@language' => 'fr') |
||
61 | ), |
||
62 | 'image' => '//upload.wikimedia.org/wikipedia/commons/thumb/8/80/Wikipedia-logo-v2.svg/64px-Wikipedia-logo-v2.svg.png', |
||
63 | 'target' => 'http://en.wikipedia.org/wiki/Douglas_Adams' |
||
64 | ) |
||
65 | ), |
||
66 | 'image' => (object) array( |
||
67 | '@type' => 'ImageObject', |
||
68 | '@id' => 'http://commons.wikimedia.org/wiki/Image:Douglas_adams_portrait_cropped.jpg', |
||
69 | 'contentUrl' => '//upload.wikimedia.org/wikipedia/commons/c/c0/Douglas_adams_portrait_cropped.jpg', |
||
70 | 'name' => 'Douglas adams portrait cropped.jpg', |
||
71 | 'width' => 100, |
||
72 | 'height' => 200 |
||
73 | ), |
||
74 | '@reverse' => (object) array( |
||
75 | 'about'=> (object) array( |
||
76 | '@type' => 'Article', |
||
77 | '@id'=> 'http://en.wikipedia.org/wiki/Douglas_Adams', |
||
78 | 'inLanguage'=> 'en', |
||
79 | 'headline'=> 'Fooo barr baz gaaaaaaa...', |
||
80 | 'author'=> (object) array( |
||
81 | '@type'=> 'Organization', |
||
82 | '@id' => 'http://www.wikidata.org/entity/Q52', |
||
83 | 'name' => 'Wikipedia' |
||
84 | ), |
||
85 | 'license'=> 'http://creativecommons.org/licenses/by-sa/3.0/' |
||
86 | ) |
||
87 | ) |
||
88 | ), |
||
89 | new FormatterOptions(array( |
||
90 | JsonLdEntityFormatter::OPT_ENTITY_BASE_URI => 'http://www.wikidata.org/entity/', |
||
91 | ValueFormatter::OPT_LANG => 'en' |
||
92 | )) |
||
93 | ), |
||
94 | array( |
||
95 | $item, |
||
96 | (object) array( |
||
97 | '@type' => 'Thing', |
||
98 | '@id' => 'http://www.wikidata.org/entity/Q42', |
||
99 | 'name' => 'Q42', |
||
100 | 'potentialAction' => array( |
||
101 | (object) array( |
||
102 | '@type' => 'ViewAction', |
||
103 | 'name' => array( |
||
104 | (object) array('@value' => 'View on Wikidata', '@language' => 'en'), |
||
105 | (object) array('@value' => 'Voir sur Wikidata', '@language' => 'fr') |
||
106 | ), |
||
107 | 'image' => '//upload.wikimedia.org/wikipedia/commons/f/ff/Wikidata-logo.svg', |
||
108 | 'target' => '//www.wikidata.org/entity/Q42' |
||
109 | ) |
||
110 | ) |
||
111 | ), |
||
112 | new FormatterOptions(array( |
||
113 | JsonLdEntityFormatter::OPT_ENTITY_BASE_URI => 'http://www.wikidata.org/entity/', |
||
114 | ValueFormatter::OPT_LANG => 'ru' |
||
115 | )) |
||
116 | ) |
||
117 | ); |
||
118 | } |
||
119 | |||
150 |
It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.
We recommend to add an additional type check (or disallow null for the parameter):