Completed
Push — master ( 689084...daf696 )
by Joao
10s
created

src/HandleOutput/XmlHandler.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace ByJG\RestServer\HandleOutput;
4
5
use ByJG\RestServer\ServiceAbstract;
6
use ByJG\Serializer\Formatter\XmlFormatter;
7
use Whoops\Handler\XmlResponseHandler;
8
9 View Code Duplication
class XmlHandler implements HandleOutputInterface
0 ignored issues
show
This class seems to be duplicated in your project.

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.

Loading history...
10
{
11
    public function writeHeader()
12
    {
13
        header('Content-Type: text/xml');
14
    }
15
16
    public function writeOutput(ServiceAbstract $instance)
17
    {
18
19
        $serialized = $instance->getResponse()->getResponseBag()->process();
20
        return (new XmlFormatter())->process($serialized);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The expression (new \ByJG\Serializer\Fo...->process($serialized); of type string|false adds false to the return on line 20 which is incompatible with the return type declared by the interface ByJG\RestServer\HandleOu...tInterface::writeOutput of type string. It seems like you forgot to handle an error condition.
Loading history...
21
    }
22
23
    public function getErrorHandler()
24
    {
25
        return new XmlResponseHandler();
26
    }
27
}
28