Conditions | 3 |
Paths | 3 |
Total Lines | 20 |
Code Lines | 14 |
Lines | 20 |
Ratio | 100 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
30 | public function createRequest($options) |
||
31 | { |
||
32 | if (!$options instanceof UpdateOptions) { |
||
33 | throw new \RuntimeException('Options must be instance of ' . UpdateOptions::class); |
||
34 | } |
||
35 | |||
36 | if (null === $options->getUniqueServiceName()) { |
||
37 | throw new \RuntimeException('Unique service name not specified.'); |
||
38 | } |
||
39 | |||
40 | $request = new NotifyRequest(); |
||
41 | return $request |
||
42 | ->withRequestTarget('*') |
||
43 | ->withProtocolVersion('1.1') |
||
44 | ->withHeader('HOST', (string)$request->getUri()) |
||
45 | ->withHeader('LOCATION', (string)$options->getDescriptionUrl()) |
||
46 | ->withHeader('NT', (string)$options->getNotificationType()) |
||
47 | ->withHeader('NTS', '"ssdp:update"') |
||
48 | ->withHeader('USN', (string)$options->getUniqueServiceName()); |
||
49 | } |
||
50 | } |
||
51 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.