Completed
Pull Request — develop (#27)
by Chris
02:45
created

Resolution   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 34
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A fromString() 0 6 1
A getWidth() 0 4 1
A getHeight() 0 4 1
A __toString() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the PhpM3u8 package.
5
 *
6
 * (c) Chrisyue <https://chrisyue.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Chrisyue\PhpM3u8\Value\Attribute;
13
14
class Resolution
15
{
16
    private $width;
17
18
    private $height;
19
20
    public function __construct(int $width, int $height)
21
    {
22
        $this->width = $width;
23
        $this->height = $height;
24
    }
25
26
    public static function fromString(string $string)
27
    {
28
        [$width, $height] = explode('x', $string);
0 ignored issues
show
Bug introduced by
The variable $width does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
Bug introduced by
The variable $height does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
29
30
        return new self($width, $height);
31
    }
32
33
    public function getWidth()
34
    {
35
        return $this->width;
36
    }
37
38
    public function getHeight()
39
    {
40
        return $this->height;
41
    }
42
43
    public function __toString()
44
    {
45
        return sprintf('%dx%d', $this->width, $this->height);
46
    }
47
}
48