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

jojo1981 / polling / 17515333845

06 Sep 2025 01:52PM UTC coverage: 80.0%. Remained the same
17515333845

push

github

web-flow
Merge pull request #3 from jojo1981/feature/upgrade-php-versions

Fix: Make compatible with PHP versions: ^8.0|^8.1|^8.2|^8.3|^8.4

7 of 10 new or added lines in 3 files covered. (70.0%)

52 of 65 relevant lines covered (80.0%)

12.92 hits per line

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

55.56
/src/Value/UnsignedInteger.php
1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of the jojo1981/polling package
4
 *
5
 * Copyright (c) 2021 Joost Nijhuis <jnijhuis81@gmail.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed in the root of the source code
9
 */
10
namespace Jojo1981\Polling\Value;
11

12
use Jojo1981\Contracts\Exception\ValueExceptionInterface;
13
use Jojo1981\Contracts\HashableInterface;
14
use Jojo1981\Contracts\ValueInterface;
15
use Jojo1981\Polling\Exception\ValueException;
16
use function hash;
17
use function is_int;
18
use function sprintf;
19

20
/**
21
 * @package Jojo1981\Polling\Value
22
 */
23
final class UnsignedInteger implements ValueInterface, HashableInterface
24
{
25
    /** @var int */
26
    private int $value;
27

28
    /**
29
     * @param int $value
30
     * @throws ValueExceptionInterface
31
     */
32
    public function __construct($value)
33
    {
34
        $this->value = self::assertValue($value);
20✔
35
    }
36

37
    /**
38
     * @param ValueInterface $otherValue
39
     * @return bool
40
     */
41
    public function match(ValueInterface $otherValue): bool
42
    {
NEW
43
        return $otherValue instanceof self && $otherValue->getValue() === $this->getValue();
×
44
    }
45

46
    /**
47
     * @return int
48
     */
49
    public function getValue(): int
50
    {
51
        return $this->value;
15✔
52
    }
53

54
    /**
55
     * @return string
56
     */
57
    public function getHash(): string
58
    {
59
        return hash('sha256', (string) $this->value);
×
60
    }
61

62
    /**
63
     * @param mixed $value
64
     * @return int
65
     * @throws ValueExceptionInterface
66
     */
67
    private static function assertValue($value): int
68
    {
69
        if (!is_int($value)) {
20✔
70
            throw new ValueException('Value for UnsignedInteger should be be of type integer');
×
71
        }
72
        if ($value < 0) {
20✔
73
            throw new ValueException(sprintf('Value for UnsignedInteger should be higher than or equals zero. Given value: `%d`.', $value));
×
74
        }
75

76
        return $value;
20✔
77
    }
78
}
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

© 2026 Coveralls, Inc