• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

FastyBird / json-api / 10238182751

04 Aug 2024 05:56PM UTC coverage: 4.214% (-0.09%) from 4.302%
10238182751

push

github

web-flow
Merge pull request #2 from FastyBird/feature/constructor-params

Added parameters from entity constructor

0 of 41 new or added lines in 3 files covered. (0.0%)

9 existing lines in 2 files now uncovered.

41 of 973 relevant lines covered (4.21%)

0.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Exceptions/JsonApiMultipleError.php
1
<?php declare(strict_types = 1);
2

3
/**
4
 * MultipleErrorException.php
5
 *
6
 * @license        More in LICENSE.md
7
 * @copyright      https://www.fastybird.com
8
 * @author         Adam Kadlec <adam.kadlec@fastybird.com>
9
 * @package        FastyBird:JsonApi!
10
 * @subpackage     Exceptions
11
 * @since          0.1.0
12
 *
13
 * @date           06.03.18
14
 */
15

16
namespace FastyBird\JsonApi\Exceptions;
17

18
use Exception as PHPException;
19
use Fig\Http\Message\StatusCodeInterface;
20
use Neomerx\JsonApi as NeomerxJsonApi;
21

22
/**
23
 * Process multiple error
24
 *
25
 * @package        FastyBird:JsonApi!
26
 * @subpackage     Exceptions
27
 *
28
 * @author         Adam Kadlec <adam.kadlec@fastybird.com>
29
 */
30
class JsonApiMultipleError extends PHPException implements JsonApi
31
{
32

33
        /** @var array<NeomerxJsonApi\Schema\Error> */
34
        private array $errors = [];
35

36
        public function __construct()
37
        {
38
                parent::__construct(
×
39
                        'Json:API multiple errors',
×
40
                        StatusCodeInterface::STATUS_UNPROCESSABLE_ENTITY,
×
UNCOV
41
                );
×
42
        }
43

44
        /**
45
         * @param array<string>|null $source
46
         */
47
        public function addError(
48
                int $code,
49
                string $title,
50
                string|null $detail = null,
51
                array|null $source = null,
52
                string|null $type = null,
53
        ): void
54
        {
55
                $this->errors[] = new NeomerxJsonApi\Schema\Error(
×
56
                        $type,
×
57
                        null,
×
58
                        null,
×
59
                        (string) $code,
×
60
                        (string) $code,
×
61
                        $title,
×
62
                        $detail,
×
63
                        $source,
×
UNCOV
64
                );
×
65
        }
66

67
        public function hasErrors(): bool
68
        {
UNCOV
69
                return $this->errors !== [];
×
70
        }
71

72
        /**
73
         * @return array<NeomerxJsonApi\Schema\Error>
74
         */
75
        public function getErrors(): array
76
        {
UNCOV
77
                return $this->errors;
×
78
        }
79

80
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc