Passed
Push — master ( 1e8bfe...85c284 )
by Sébastien
03:02
created

BitrateAssertionsTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 3
dl 0
loc 11
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A ensureValidBitRateUnit() 0 4 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Soluble\MediaTools\Util\Assert;
6
7
use Soluble\MediaTools\Exception\InvalidArgumentException;
8
9
trait BitrateAssertionsTrait
10
{
11
    /**
12
     * Ensure that a bitrate is valid (optional unit: k or M ).
13
     *
14
     * @throws InvalidArgumentException
15
     */
16 3
    protected function ensureValidBitRateUnit(string $bitrate): void
17
    {
18 3
        if (preg_match('/^\d+(k|M)?$/i', $bitrate) !== 1) {
19 1
            throw new InvalidArgumentException(sprintf('"%s"', $bitrate));
20
        }
21 2
    }
22
}
23