| Conditions | 1 |
| Total Lines | 82 |
| 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 |
||
| 42 | private function mockResponse(): ResponseInterface |
||
| 43 | { |
||
| 44 | $c = new class($this) implements ResponseInterface |
||
| 45 | { |
||
| 46 | private $unitTestInstance; |
||
| 47 | public function __construct(EmbedContainerTest $unitTestInstance) |
||
| 48 | { |
||
| 49 | $this->unitTestInstance = $unitTestInstance; |
||
| 50 | } |
||
| 51 | public function getStatusCode() |
||
| 52 | { |
||
| 53 | return 200; |
||
| 54 | } |
||
| 55 | public function getBody() |
||
| 56 | { |
||
| 57 | // first request is to the video HTML to get to find the oembed link |
||
| 58 | // second request is to the oembed endpoint to fetch JSON |
||
| 59 | if ($this->unitTestInstance->firstRequest) { |
||
| 60 | return '<html><link rel="alternate" type="application/json+oembed" href="https://www.youtube.com/oembed?format=json&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DiRXJXaLV0n4" title="Try to stay SERIOUS -The most popular CAT videos"></html>'; |
||
| 61 | } else { |
||
| 62 | return json_encode([ |
||
| 63 | 'author_url' => 'https://www.youtube.com/channel/UCR2KG2dK1tAkwZZjm7rAiSg', |
||
| 64 | 'thumbnail_width' => 480, |
||
| 65 | 'title' => 'Try to stay SERIOUS -The most popular CAT videos', |
||
| 66 | 'width' => 480, |
||
| 67 | 'provider_name' => 'YouTube', |
||
| 68 | 'author_name' => 'Tiger Funnies', |
||
| 69 | 'height' => 270, |
||
| 70 | 'version' => '1.0', |
||
| 71 | 'type' => 'video', |
||
| 72 | // phpcs:ignore |
||
| 73 | 'html' => '<iframe width="480" height="270" src="https://www.youtube.com/embed/iRXJXaLV0n4?feature=oembed" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>', |
||
| 74 | 'provider_url' => 'https://www.youtube.com/', |
||
| 75 | 'thumbnail_height' => 360, |
||
| 76 | 'thumbnail_url' => 'https://i.ytimg.com/vi/iRXJXaLV0n4/hqdefault.jpg', |
||
| 77 | ]); |
||
| 78 | } |
||
| 79 | } |
||
| 80 | public function withStatus($code, $reasonPhrase = '') |
||
| 81 | { |
||
| 82 | return $this; |
||
| 83 | } |
||
| 84 | public function getReasonPhrase() |
||
| 85 | { |
||
| 86 | } |
||
| 87 | public function getProtocolVersion() |
||
| 88 | { |
||
| 89 | } |
||
| 90 | public function withProtocolVersion($version) |
||
| 91 | { |
||
| 92 | return $this; |
||
| 93 | } |
||
| 94 | public function getHeaders() |
||
| 95 | { |
||
| 96 | } |
||
| 97 | public function hasHeader($name) |
||
| 98 | { |
||
| 99 | } |
||
| 100 | public function getHeader($name) |
||
| 101 | { |
||
| 102 | } |
||
| 103 | public function getHeaderLine($name) |
||
| 104 | { |
||
| 105 | } |
||
| 106 | public function withHeader($name, $value) |
||
| 107 | { |
||
| 108 | return $this; |
||
| 109 | } |
||
| 110 | public function withAddedHeader($name, $value) |
||
| 111 | { |
||
| 112 | return $this; |
||
| 113 | } |
||
| 114 | public function withoutHeader($name) |
||
| 115 | { |
||
| 116 | return $this; |
||
| 117 | } |
||
| 118 | public function withBody(StreamInterface $body) |
||
| 119 | { |
||
| 120 | return $this; |
||
| 121 | } |
||
| 122 | }; |
||
| 123 | return new $c($this); |
||
| 124 | } |
||
| 268 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths