Completed
Pull Request — master (#87)
by Ankit
05:04
created

Server::handleDownload()   A

Complexity

Conditions 5
Paths 4

Size

Total Lines 21
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 5

Importance

Changes 0
Metric Value
cc 5
eloc 11
nc 4
nop 0
dl 0
loc 21
ccs 12
cts 12
cp 1
crap 5
rs 9.6111
c 0
b 0
f 0
1
<?php
2
3
namespace TusPhp\Tus;
4
5
use TusPhp\File;
6
use Carbon\Carbon;
7
use TusPhp\Request;
8
use TusPhp\Response;
9
use Ramsey\Uuid\Uuid;
10
use TusPhp\Cache\Cacheable;
11
use TusPhp\Middleware\Middleware;
12
use TusPhp\Exception\FileException;
13
use TusPhp\Exception\ConnectionException;
14
use TusPhp\Exception\OutOfRangeException;
15
use Symfony\Component\HttpFoundation\BinaryFileResponse;
16
use Symfony\Component\HttpFoundation\Response as HttpResponse;
17
18
class Server extends AbstractTus
19
{
20
    /** @const string Tus Creation Extension */
21
    const TUS_EXTENSION_CREATION = 'creation';
22
23
    /** @const string Tus Termination Extension */
24
    const TUS_EXTENSION_TERMINATION = 'termination';
25
26
    /** @const string Tus Checksum Extension */
27
    const TUS_EXTENSION_CHECKSUM = 'checksum';
28
29
    /** @const string Tus Expiration Extension */
30
    const TUS_EXTENSION_EXPIRATION = 'expiration';
31
32
    /** @const string Tus Concatenation Extension */
33
    const TUS_EXTENSION_CONCATENATION = 'concatenation';
34
35
    /** @const array All supported tus extensions */
36
    const TUS_EXTENSIONS = [
37
        self::TUS_EXTENSION_CREATION,
38
        self::TUS_EXTENSION_TERMINATION,
39
        self::TUS_EXTENSION_CHECKSUM,
40
        self::TUS_EXTENSION_EXPIRATION,
41
        self::TUS_EXTENSION_CONCATENATION,
42
    ];
43
44
    /** @const int 460 Checksum Mismatch */
45
    const HTTP_CHECKSUM_MISMATCH = 460;
46
47
    /** @const string Default checksum algorithm */
48
    const DEFAULT_CHECKSUM_ALGORITHM = 'sha256';
49
50
    /** @var Request */
51
    protected $request;
52
53
    /** @var Response */
54
    protected $response;
55
56
    /** @var string */
57
    protected $uploadDir;
58
59
    /** @var string */
60
    protected $uploadKey;
61
62
    /** @var Middleware */
63
    protected $middleware;
64
65
    /**
66
     * @var int Max upload size in bytes
67
     *          Default 0, no restriction.
68
     */
69
    protected $maxUploadSize = 0;
70
71
    /**
72
     * TusServer constructor.
73
     *
74
     * @param Cacheable|string $cacheAdapter
75
     */
76 3
    public function __construct($cacheAdapter = 'file')
77
    {
78 3
        $this->request    = new Request;
79 3
        $this->response   = new Response;
80 3
        $this->middleware = new Middleware;
81 3
        $this->uploadDir  = dirname(__DIR__, 2) . DIRECTORY_SEPARATOR . 'uploads';
82
83 3
        $this->setCache($cacheAdapter);
84 3
    }
85
86
    /**
87
     * Set upload dir.
88
     *
89
     * @param string $path
90
     *
91
     * @return Server
92
     */
93 2
    public function setUploadDir(string $path) : self
94
    {
95 2
        $this->uploadDir = $path;
96
97 2
        return $this;
98
    }
99
100
    /**
101
     * Get upload dir.
102
     *
103
     * @return string
104
     */
105 1
    public function getUploadDir() : string
106
    {
107 1
        return $this->uploadDir;
108
    }
109
110
    /**
111
     * Get request.
112
     *
113
     * @return Request
114
     */
115 1
    public function getRequest() : Request
116
    {
117 1
        return $this->request;
118
    }
119
120
    /**
121
     * Get request.
122
     *
123
     * @return Response
124
     */
125 1
    public function getResponse() : Response
126
    {
127 1
        return $this->response;
128
    }
129
130
    /**
131
     * Get file checksum.
132
     *
133
     * @param string $filePath
134
     *
135
     * @return string
136
     */
137 1
    public function getServerChecksum(string $filePath) : string
138
    {
139 1
        return hash_file($this->getChecksumAlgorithm(), $filePath);
140
    }
141
142
    /**
143
     * Get checksum algorithm.
144
     *
145
     * @return string|null
146
     */
147 1
    public function getChecksumAlgorithm() : ?string
148
    {
149 1
        $checksumHeader = $this->getRequest()->header('Upload-Checksum');
150
151 1
        if (empty($checksumHeader)) {
152 1
            return self::DEFAULT_CHECKSUM_ALGORITHM;
153
        }
154
155 1
        list($checksumAlgorithm, /* $checksum */) = explode(' ', $checksumHeader);
156
157 1
        return $checksumAlgorithm;
158
    }
159
160
    /**
161
     * Set upload key.
162
     *
163
     * @param string $key
164
     *
165
     * @return Server
166
     */
167 1
    public function setUploadKey(string $key) : self
168
    {
169 1
        $this->uploadKey = $key;
170
171 1
        return $this;
172
    }
173
174
    /**
175
     * Get upload key from header.
176
     *
177
     * @return string|HttpResponse
178
     */
179 4
    public function getUploadKey()
180
    {
181 4
        if ( ! empty($this->uploadKey)) {
182 1
            return $this->uploadKey;
183
        }
184
185 3
        $key = $this->getRequest()->header('Upload-Key') ?? Uuid::uuid4()->toString();
186
187 3
        if (empty($key)) {
188 1
            return $this->response->send(null, HttpResponse::HTTP_BAD_REQUEST);
189
        }
190
191 2
        $this->uploadKey = $key;
192
193 2
        return $this->uploadKey;
194
    }
195
196
    /**
197
     * Set middleware.
198
     *
199
     * @param Middleware $middleware
200
     *
201
     * @return self
202
     */
203 1
    public function setMiddleware(Middleware $middleware) : self
204
    {
205 1
        $this->middleware = $middleware;
206
207 1
        return $this;
208
    }
209
210
    /**
211
     * Get middleware.
212
     *
213
     * @return Middleware
214
     */
215 1
    public function middleware() : Middleware
216
    {
217 1
        return $this->middleware;
218
    }
219
220
    /**
221
     * Set max upload size.
222
     *
223
     * @param int $uploadSize
224
     *
225
     * @return Server
226
     */
227 2
    public function setMaxUploadSize(int $uploadSize) : self
228
    {
229 2
        $this->maxUploadSize = $uploadSize;
230
231 2
        return $this;
232
    }
233
234
    /**
235
     * Get max upload size.
236
     *
237
     * @return int
238
     */
239 1
    public function getMaxUploadSize() : int
240
    {
241 1
        return $this->maxUploadSize;
242
    }
243
244
    /**
245
     * Handle all HTTP request.
246
     *
247
     * @return HttpResponse|BinaryFileResponse
248
     */
249 3
    public function serve()
250
    {
251 3
        $this->applyMiddleware();
252
253 3
        $requestMethod = $this->getRequest()->method();
254
255 3
        if ( ! in_array($requestMethod, $this->getRequest()->allowedHttpVerbs())) {
256 1
            return $this->response->send(null, HttpResponse::HTTP_METHOD_NOT_ALLOWED);
257
        }
258
259 2
        $method = 'handle' . ucfirst(strtolower($requestMethod));
260
261 2
        return $this->{$method}();
262
    }
263
264
    /**
265
     * Apply middleware.
266
     *
267
     * @return void
268
     */
269 1
    protected function applyMiddleware()
270
    {
271 1
        $middleware = $this->middleware()->list();
272
273 1
        foreach ($middleware as $m) {
274 1
            $m->handle($this->getRequest(), $this->getResponse());
275
        }
276 1
    }
277
278
    /**
279
     * Handle OPTIONS request.
280
     *
281
     * @return HttpResponse
282
     */
283 2
    protected function handleOptions() : HttpResponse
284
    {
285
        $headers = [
286 2
            'Allow' => implode(',', $this->request->allowedHttpVerbs()),
287 2
            'Tus-Version' => self::TUS_PROTOCOL_VERSION,
288 2
            'Tus-Extension' => implode(',', self::TUS_EXTENSIONS),
289 2
            'Tus-Checksum-Algorithm' => $this->getSupportedHashAlgorithms(),
290
        ];
291
292 2
        $maxUploadSize = $this->getMaxUploadSize();
293
294 2
        if ($maxUploadSize > 0) {
295 1
            $headers['Tus-Max-Size'] = $maxUploadSize;
296
        }
297
298 2
        return $this->response->send(null, HttpResponse::HTTP_OK, $headers);
299
    }
300
301
    /**
302
     * Handle HEAD request.
303
     *
304
     * @return HttpResponse
305
     */
306 5
    protected function handleHead() : HttpResponse
307
    {
308 5
        $key = $this->request->key();
309
310 5
        if ( ! $fileMeta = $this->cache->get($key)) {
311 1
            return $this->response->send(null, HttpResponse::HTTP_NOT_FOUND);
312
        }
313
314 4
        $offset = $fileMeta['offset'] ?? false;
315
316 4
        if (false === $offset) {
317 1
            return $this->response->send(null, HttpResponse::HTTP_GONE);
318
        }
319
320 3
        return $this->response->send(null, HttpResponse::HTTP_OK, $this->getHeadersForHeadRequest($fileMeta));
321
    }
322
323
    /**
324
     * Handle POST request.
325
     *
326
     * @return HttpResponse
327
     */
328 5
    protected function handlePost() : HttpResponse
329
    {
330 5
        $fileName   = $this->getRequest()->extractFileName();
331 5
        $uploadType = self::UPLOAD_TYPE_NORMAL;
332
333 5
        if (empty($fileName)) {
334 1
            return $this->response->send(null, HttpResponse::HTTP_BAD_REQUEST);
335
        }
336
337 4
        if ( ! $this->verifyUploadSize()) {
338 1
            return $this->response->send(null, HttpResponse::HTTP_REQUEST_ENTITY_TOO_LARGE);
339
        }
340
341 3
        $uploadKey = $this->getUploadKey();
342 3
        $filePath  = $this->uploadDir . DIRECTORY_SEPARATOR . $fileName;
343
344 3
        if ($this->getRequest()->isFinal()) {
345 1
            return $this->handleConcatenation($fileName, $filePath);
346
        }
347
348 2
        if ($this->getRequest()->isPartial()) {
349 1
            $filePath   = $this->getPathForPartialUpload($uploadKey) . $fileName;
350 1
            $uploadType = self::UPLOAD_TYPE_PARTIAL;
351
        }
352
353 2
        $checksum = $this->getClientChecksum();
354 2
        $location = $this->getRequest()->url() . $this->getApiPath() . '/' . $uploadKey;
355
356 2
        $file = $this->buildFile([
357 2
            'name' => $fileName,
358 2
            'offset' => 0,
359 2
            'size' => $this->getRequest()->header('Upload-Length'),
360 2
            'file_path' => $filePath,
361 2
            'location' => $location,
362 2
        ])->setChecksum($checksum);
363
364 2
        $this->cache->set($uploadKey, $file->details() + ['upload_type' => $uploadType]);
365
366 2
        return $this->response->send(
367 2
            null,
368 2
            HttpResponse::HTTP_CREATED,
369
            [
370 2
                'Location' => $location,
371 2
                'Upload-Expires' => $this->cache->get($uploadKey)['expires_at'],
372
            ]
373
        );
374
    }
375
376
    /**
377
     * Handle file concatenation.
378
     *
379
     * @param string $fileName
380
     * @param string $filePath
381
     *
382
     * @return HttpResponse
383
     */
384 2
    protected function handleConcatenation(string $fileName, string $filePath) : HttpResponse
385
    {
386 2
        $partials  = $this->getRequest()->extractPartials();
387 2
        $uploadKey = $this->getUploadKey();
388 2
        $files     = $this->getPartialsMeta($partials);
389 2
        $filePaths = array_column($files, 'file_path');
390 2
        $location  = $this->getRequest()->url() . $this->getApiPath() . '/' . $uploadKey;
391
392 2
        $file = $this->buildFile([
393 2
            'name' => $fileName,
394 2
            'offset' => 0,
395 2
            'size' => 0,
396 2
            'file_path' => $filePath,
397 2
            'location' => $location,
398 2
        ])->setFilePath($filePath);
399
400 2
        $file->setOffset($file->merge($files));
401
402
        // Verify checksum.
403 2
        $checksum = $this->getServerChecksum($filePath);
404
405 2
        if ($checksum !== $this->getClientChecksum()) {
406 1
            return $this->response->send(null, self::HTTP_CHECKSUM_MISMATCH);
407
        }
408
409 1
        $this->cache->set($uploadKey, $file->details() + ['upload_type' => self::UPLOAD_TYPE_FINAL]);
410
411
        // Cleanup.
412 1
        if ($file->delete($filePaths, true)) {
413 1
            $this->cache->deleteAll($partials);
414
        }
415
416 1
        return $this->response->send(
417 1
            ['data' => ['checksum' => $checksum]],
418 1
            HttpResponse::HTTP_CREATED,
419
            [
420 1
                'Location' => $location,
421
            ]
422
        );
423
    }
424
425
    /**
426
     * Handle PATCH request.
427
     *
428
     * @return HttpResponse
429
     */
430 8
    protected function handlePatch() : HttpResponse
431
    {
432 8
        $uploadKey = $this->request->key();
433
434 8
        if ( ! $meta = $this->cache->get($uploadKey)) {
435 1
            return $this->response->send(null, HttpResponse::HTTP_GONE);
436
        }
437
438 7
        $status = $this->verifyPatchRequest($meta);
439
440 7
        if (HttpResponse::HTTP_OK !== $status) {
441 2
            return $this->response->send(null, $status);
442
        }
443
444 5
        $file     = $this->buildFile($meta);
445 5
        $checksum = $meta['checksum'];
446
447
        try {
448 5
            $fileSize = $file->getFileSize();
449 5
            $offset   = $file->setKey($uploadKey)->setChecksum($checksum)->upload($fileSize);
450
451
            // If upload is done, verify checksum.
452 2
            if ($offset === $fileSize && ! $this->verifyChecksum($checksum, $meta['file_path'])) {
453 2
                return $this->response->send(null, self::HTTP_CHECKSUM_MISMATCH);
454
            }
455 3
        } catch (FileException $e) {
456 1
            return $this->response->send($e->getMessage(), HttpResponse::HTTP_UNPROCESSABLE_ENTITY);
457 2
        } catch (OutOfRangeException $e) {
458 1
            return $this->response->send(null, HttpResponse::HTTP_REQUESTED_RANGE_NOT_SATISFIABLE);
459 1
        } catch (ConnectionException $e) {
460 1
            return $this->response->send(null, HttpResponse::HTTP_CONTINUE);
461
        }
462
463 1
        return $this->response->send(null, HttpResponse::HTTP_NO_CONTENT, [
464 1
            'Content-Type' => 'application/offset+octet-stream',
465 1
            'Upload-Expires' => $this->cache->get($uploadKey)['expires_at'],
466 1
            'Upload-Offset' => $offset,
467
        ]);
468
    }
469
470
    /**
471
     * Verify PATCH request.
472
     *
473
     * @param array $meta
474
     *
475
     * @return int
476
     */
477 7
    protected function verifyPatchRequest(array $meta) : int
478
    {
479 7
        if (self::UPLOAD_TYPE_FINAL === $meta['upload_type']) {
480 1
            return HttpResponse::HTTP_FORBIDDEN;
481
        }
482
483 6
        $uploadOffset = $this->request->header('upload-offset');
484
485 6
        if ($uploadOffset && $uploadOffset !== (string) $meta['offset']) {
486 1
            return HttpResponse::HTTP_CONFLICT;
487
        }
488
489 5
        return HttpResponse::HTTP_OK;
490
    }
491
492
    /**
493
     * Handle GET request.
494
     *
495
     * As per RFC7231, we need to treat HEAD and GET as an identical request.
496
     * All major PHP frameworks follows the same and silently transforms each
497
     * HEAD requests to GET.
498
     *
499
     * @return BinaryFileResponse|HttpResponse
500
     */
501 5
    protected function handleGet()
502
    {
503
        // We will treat '/files/<key>/get' as a download request.
504 5
        if ('get' === $this->request->key()) {
505 4
            return $this->handleDownload();
506
        }
507
508 1
        return $this->handleHead();
509
    }
510
511
    /**
512
     * Handle Download request.
513
     *
514
     * @return BinaryFileResponse|HttpResponse
515
     */
516 4
    protected function handleDownload()
517
    {
518 4
        $path = explode('/', str_replace('/get', '', $this->request->path()));
519 4
        $key  = end($path);
520
521 4
        if ($this->request->path() === $this->getApiPath()) {
522 1
            return $this->response->send('400 bad request.', HttpResponse::HTTP_BAD_REQUEST);
523
        }
524
525 3
        if ( ! $fileMeta = $this->cache->get($key)) {
526 1
            return $this->response->send('404 upload not found.', HttpResponse::HTTP_NOT_FOUND);
527
        }
528
529 2
        $resource = $fileMeta['file_path'] ?? null;
530 2
        $fileName = $fileMeta['name'] ?? null;
531
532 2
        if ( ! $resource || ! file_exists($resource)) {
533 1
            return $this->response->send('404 upload not found.', HttpResponse::HTTP_NOT_FOUND);
534
        }
535
536 1
        return $this->response->download($resource, $fileName);
537
    }
538
539
    /**
540
     * Handle DELETE request.
541
     *
542
     * @return HttpResponse
543
     */
544 3
    protected function handleDelete() : HttpResponse
545
    {
546 3
        $key      = $this->request->key();
547 3
        $fileMeta = $this->cache->get($key);
548 3
        $resource = $fileMeta['file_path'] ?? null;
549
550 3
        if ( ! $resource) {
551 1
            return $this->response->send(null, HttpResponse::HTTP_NOT_FOUND);
552
        }
553
554 2
        $isDeleted = $this->cache->delete($key);
555
556 2
        if ( ! $isDeleted || ! file_exists($resource)) {
557 1
            return $this->response->send(null, HttpResponse::HTTP_GONE);
558
        }
559
560 1
        unlink($resource);
561
562 1
        return $this->response->send(null, HttpResponse::HTTP_NO_CONTENT, [
563 1
            'Tus-Extension' => self::TUS_EXTENSION_TERMINATION,
564
        ]);
565
    }
566
567
    /**
568
     * Get required headers for head request.
569
     *
570
     * @param array $fileMeta
571
     *
572
     * @return array
573
     */
574 4
    protected function getHeadersForHeadRequest(array $fileMeta) : array
575
    {
576
        $headers = [
577 4
            'Upload-Length' => (int) $fileMeta['size'],
578 4
            'Upload-Offset' => (int) $fileMeta['offset'],
579 4
            'Cache-Control' => 'no-store',
580
        ];
581
582 4
        if (self::UPLOAD_TYPE_FINAL === $fileMeta['upload_type'] && $fileMeta['size'] !== $fileMeta['offset']) {
583 2
            unset($headers['Upload-Offset']);
584
        }
585
586 4
        if (self::UPLOAD_TYPE_NORMAL !== $fileMeta['upload_type']) {
587 3
            $headers += ['Upload-Concat' => $fileMeta['upload_type']];
588
        }
589
590 4
        return $headers;
591
    }
592
593
    /**
594
     * Build file object.
595
     *
596
     * @param array $meta
597
     *
598
     * @return File
599
     */
600 1
    protected function buildFile(array $meta) : File
601
    {
602 1
        $file = new File($meta['name'], $this->cache);
603
604 1
        if (array_key_exists('offset', $meta)) {
605 1
            $file->setMeta($meta['offset'], $meta['size'], $meta['file_path'], $meta['location']);
606
        }
607
608 1
        return $file;
609
    }
610
611
    /**
612
     * Get list of supported hash algorithms.
613
     *
614
     * @return string
615
     */
616 1
    protected function getSupportedHashAlgorithms() : string
617
    {
618 1
        $supportedAlgorithms = hash_algos();
619
620 1
        $algorithms = [];
621 1
        foreach ($supportedAlgorithms as $hashAlgo) {
622 1
            if (false !== strpos($hashAlgo, ',')) {
623 1
                $algorithms[] = "'{$hashAlgo}'";
624
            } else {
625 1
                $algorithms[] = $hashAlgo;
626
            }
627
        }
628
629 1
        return implode(',', $algorithms);
630
    }
631
632
    /**
633
     * Verify and get upload checksum from header.
634
     *
635
     * @return string|HttpResponse
636
     */
637 4
    protected function getClientChecksum()
638
    {
639 4
        $checksumHeader = $this->getRequest()->header('Upload-Checksum');
640
641 4
        if (empty($checksumHeader)) {
642 1
            return '';
643
        }
644
645 3
        list($checksumAlgorithm, $checksum) = explode(' ', $checksumHeader);
646
647 3
        $checksum = base64_decode($checksum);
648
649 3
        if ( ! in_array($checksumAlgorithm, hash_algos()) || false === $checksum) {
650 2
            return $this->response->send(null, HttpResponse::HTTP_BAD_REQUEST);
651
        }
652
653 1
        return $checksum;
654
    }
655
656
    /**
657
     * Get expired but incomplete uploads.
658
     *
659
     * @param array|null $contents
660
     *
661
     * @return bool
662
     */
663 3
    protected function isExpired($contents) : bool
664
    {
665 3
        $isExpired = empty($contents['expires_at']) || Carbon::parse($contents['expires_at'])->lt(Carbon::now());
666
667 3
        if ($isExpired && $contents['offset'] !== $contents['size']) {
668 3
            return true;
669
        }
670
671 2
        return false;
672
    }
673
674
    /**
675
     * Get path for partial upload.
676
     *
677
     * @param string $key
678
     *
679
     * @return string
680
     */
681 1
    protected function getPathForPartialUpload(string $key) : string
682
    {
683 1
        list($actualKey, /* $partialUploadKey */) = explode(self::PARTIAL_UPLOAD_NAME_SEPARATOR, $key);
684
685 1
        $path = $this->uploadDir . DIRECTORY_SEPARATOR . $actualKey . DIRECTORY_SEPARATOR;
686
687 1
        if ( ! file_exists($path)) {
688 1
            mkdir($path);
689
        }
690
691 1
        return $path;
692
    }
693
694
    /**
695
     * Get metadata of partials.
696
     *
697
     * @param array $partials
698
     *
699
     * @return array
700
     */
701 3
    protected function getPartialsMeta(array $partials) : array
702
    {
703 3
        $files = [];
704
705 3
        foreach ($partials as $partial) {
706 3
            $fileMeta = $this->getCache()->get($partial);
707
708 3
            $files[] = $fileMeta;
709
        }
710
711 3
        return $files;
712
    }
713
714
    /**
715
     * Delete expired resources.
716
     *
717
     * @return array
718
     */
719 2
    public function handleExpiration() : array
720
    {
721 2
        $deleted   = [];
722 2
        $cacheKeys = $this->cache->keys();
723
724 2
        foreach ($cacheKeys as $key) {
725 2
            $fileMeta = $this->cache->get($key, true);
726
727 2
            if ( ! $this->isExpired($fileMeta)) {
728 1
                continue;
729
            }
730
731 2
            if ( ! $this->cache->delete($key)) {
732 1
                continue;
733
            }
734
735 1
            if (is_writable($fileMeta['file_path'])) {
736 1
                unlink($fileMeta['file_path']);
737
            }
738
739 1
            $deleted[] = $fileMeta;
740
        }
741
742 2
        return $deleted;
743
    }
744
745
    /**
746
     * Verify max upload size.
747
     *
748
     * @return bool
749
     */
750 1
    protected function verifyUploadSize() : bool
751
    {
752 1
        $maxUploadSize = $this->getMaxUploadSize();
753
754 1
        if ($maxUploadSize > 0 && $this->getRequest()->header('Upload-Length') > $maxUploadSize) {
755 1
            return false;
756
        }
757
758 1
        return true;
759
    }
760
761
    /**
762
     * Verify checksum if available.
763
     *
764
     * @param string $checksum
765
     * @param string $filePath
766
     *
767
     * @return bool
768
     */
769 1
    protected function verifyChecksum(string $checksum, string $filePath) : bool
770
    {
771
        // Skip if checksum is empty.
772 1
        if (empty($checksum)) {
773 1
            return true;
774
        }
775
776 1
        return $checksum === $this->getServerChecksum($filePath);
777
    }
778
779
    /**
780
     * No other methods are allowed.
781
     *
782
     * @param string $method
783
     * @param array  $params
784
     *
785
     * @return HttpResponse
786
     */
787 1
    public function __call(string $method, array $params)
788
    {
789 1
        return $this->response->send(null, HttpResponse::HTTP_BAD_REQUEST);
790
    }
791
}
792