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

mlocati / nexi / 8551303918

04 Apr 2024 08:05AM UTC coverage: 2.295% (+2.3%) from 0.0%
8551303918

push

github

mlocati
Improve JSON generation, add ways to enable insecure HTTPS connections

12 of 89 new or added lines in 7 files covered. (13.48%)

2 existing lines in 2 files now uncovered.

39 of 1699 relevant lines covered (2.3%)

0.02 hits per line

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

0.0
/src/Exception/WrongFieldType.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace MLocati\Nexi\Exception;
6

7
use MLocati\Nexi\Exception;
8
use stdClass;
9

10
/**
11
 * Exception thrown when a field is not of an expected type.
12
 */
13
class WrongFieldType extends Exception
14
{
15
    /**
16
     * @var string
17
     */
18
    private $field;
19

20
    /**
21
     * @var string
22
     */
23
    private $expectedType;
24

25
    private $actualValue;
26

27
    public function __construct(string $field, string $expectedType, $actualValue, string $message = '')
28
    {
29
        $this->field = $field;
×
30
        $this->expectedType = $expectedType;
×
NEW
31
        $this->actualValue = $actualValue;
×
NEW
32
        parent::__construct($message ?: "The field {$field} has the wrong type (expected: {$expectedType}, found: {$this->getActualType()})");
×
UNCOV
33
    }
×
34

35
    /**
36
     * Get the name of the field containing the wrong value.
37
     */
38
    public function getField(): string
39
    {
40
        return $this->field;
×
41
    }
42

43
    /**
44
     * Get the type we are expecting (multiple values separated by |).
45
     */
46
    public function getExpectedType(): string
47
    {
48
        return $this->expectedType;
×
49
    }
50

51
    /**
52
     * Get the actual type of the field value.
53
     */
54
    public function getActualType(): string
55
    {
NEW
56
        $type = gettype($this->actualValue);
×
57

NEW
58
        return $type !== 'object' || $this->actualValue instanceof stdClass ? $type : get_class($this->actualValue);
×
59
    }
60

61
    /**
62
     * Get the actual value of the field value.
63
     */
64
    public function getActualValue(): string
65
    {
NEW
66
        return $this->actualValue;
×
67
    }
68
}
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