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

lmc-eu / matej-client-php / 7527331519

15 Jan 2024 10:11AM UTC coverage: 100.0%. Remained the same
7527331519

Pull #135

github

web-flow
Merge 117257645 into 9666a6254
Pull Request #135: Update to new coding standard

20 of 21 new or added lines in 5 files covered. (95.24%)

400 existing lines in 23 files now uncovered.

758 of 758 relevant lines covered (100.0%)

18.54 hits per line

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

100.0
/src/Model/Assertion.php
1
<?php declare(strict_types=1);
2

3
namespace Lmc\Matej\Model;
4

5
use Lmc\Matej\Exception\DomainException;
6
use Lmc\Matej\Exception\LogicException;
7
use Lmc\Matej\Model\Command\AbstractCommand;
8

9
/**
10
 * @method static bool allTypeIdentifier(mixed $value) Assert value is valid Matej type identifier for all values
11
 * @internal
12
 */
13
class Assertion extends \Assert\Assertion
14
{
15
    private const MAX_TYPE_IDENTIFIER_LENGTH = 100;
16
    private const MAX_BATCH_SIZE = 1000;
17

18
    protected static $exceptionClass = DomainException::class;
19

20
    /**
21
     * Assert value is valid Matej type identifier
22
     *
23
     * @param mixed $value
24
     */
25
    public static function typeIdentifier($value): bool
26
    {
UNCOV
27
        static::regex(
264✔
UNCOV
28
            $value,
264✔
UNCOV
29
            '/^[0-9A-Za-z-_]+$/',
264✔
UNCOV
30
            'Value "%s" does not match type identifier format requirement (must contain only of alphanumeric chars,'
198✔
UNCOV
31
            . ' dash or underscore)'
264✔
UNCOV
32
        );
198✔
UNCOV
33
        static::maxLength($value, self::MAX_TYPE_IDENTIFIER_LENGTH);
244✔
34

UNCOV
35
        return true;
240✔
36
    }
37

38
    /**
39
     * Assert Commands batch size to Matej is not over size limit.
40
     *
41
     * @param AbstractCommand[] $commands
42
     */
43
    public static function batchSize(array $commands): bool
44
    {
UNCOV
45
        static::lessOrEqualThan(
20✔
UNCOV
46
            count($commands),
20✔
UNCOV
47
            self::MAX_BATCH_SIZE,
20✔
UNCOV
48
            'Request contains %s commands, but at most %s is allowed in one request.'
20✔
UNCOV
49
        );
15✔
50

UNCOV
51
        return true;
12✔
52
    }
53

54
    /**
55
     * Assert that provided classname is an instance or subclass of Response
56
     */
57
    public static function isResponseClass(string $wantedClass): bool
58
    {
UNCOV
59
        if (!is_a($wantedClass, Response::class, true) &&
24✔
UNCOV
60
            !is_subclass_of($wantedClass, Response::class)
24✔
61
        ) {
UNCOV
62
            throw LogicException::forClassNotExtendingOtherClass($wantedClass, Response::class);
8✔
63
        }
64

UNCOV
65
        return true;
16✔
66
    }
67
}
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