Code Duplication    Length = 15-17 lines in 2 locations

src/Mouf/Mvc/Splash/Controllers/HttpErrorsController.php 2 locations

@@ 108-124 (lines=17) @@
105
     *
106
     * @return ResponseInterface
107
     */
108
    public function badRequest(BadRequestException $exception, ServerRequestInterface $request) : ResponseInterface
109
    {
110
        $this->exception = $exception;
111
112
        $acceptType = $request->getHeader('Accept');
113
        if (is_array($acceptType) && count($acceptType) > 0 && strpos($acceptType[0], 'json') !== false) {
114
            return new JsonResponse(['error' => ['message' => 'Bad request sent', 'type' => 'bad_request']], 400);
115
        }
116
117
        if ($this->contentFor400) {
118
            $this->contentBlock = $this->contentFor400;
119
        } else {
120
            $this->contentBlock->addFile(__DIR__.'/../../../../views/400.php', $this);
121
        }
122
123
        return HtmlResponse::create($this->template, 400);
124
    }
125
126
    /**
127
     * This function is called when a HTTP 404 error is triggered by the user.
@@ 133-147 (lines=15) @@
130
     *
131
     * @return ResponseInterface
132
     */
133
    public function pageNotFound(ServerRequestInterface $request) : ResponseInterface
134
    {
135
        $acceptType = $request->getHeader('Accept');
136
        if (is_array($acceptType) && count($acceptType) > 0 && strpos($acceptType[0], 'json') !== false) {
137
            return new JsonResponse(['error' => ['message' => 'Page not found', 'type' => 'page_not_found']], 404);
138
        }
139
140
        if ($this->contentFor404) {
141
            $this->contentBlock->addHtmlElement($this->contentFor404);
142
        } else {
143
            $this->contentBlock->addFile(__DIR__.'/../../../../views/404.php', $this);
144
        }
145
146
        return HtmlResponse::create($this->template, 404);
147
    }
148
149
    /**
150
     * (non-PHPdoc).