• 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/PollCount.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 get_class;
17
use function hash;
18
use function is_int;
19
use function sprintf;
20

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

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

38
    /**
39
     * @param mixed $value
40
     * @return int
41
     * @throws ValueExceptionInterface
42
     */
43
    private function assertValue($value): int
44
    {
45
        if (!is_int($value)) {
20✔
NEW
46
            throw new ValueException('Value for PollCount should be be of type integer');
×
47
        }
48
        if ($value < 1) {
20✔
NEW
49
            throw new ValueException(sprintf('Value for PollCount should be higher than or equals 1. Given value: `%d`.', $value));
×
50
        }
51

52
        return $value;
20✔
53
    }
54

55
    /**
56
     * @param ValueInterface $otherValue
57
     * @return bool
58
     */
59
    public function match(ValueInterface $otherValue): bool
60
    {
61
        return get_class($this) === get_class($otherValue) && $otherValue->getValue() === $this->getValue();
×
62
    }
63

64
    /**
65
     * @return int
66
     */
67
    public function getValue(): int
68
    {
69
        return $this->value;
15✔
70
    }
71

72
    /**
73
     * @return string
74
     */
75
    public function getHash(): string
76
    {
77
        return hash('sha256', (string) $this->value);
×
78
    }
79
}
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