Test Failed
Push — master ( ba03f2...dee2b3 )
by Mostafa
58s queued 15s
created

Style::extension()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Mostafaznv\Larupload\DTOs\Style;
4
5
use Exception;
6
7
8
abstract class Style
9
{
10
    public function __construct(
11
        public readonly string $name,
12
        public readonly ?int   $width = null,
13
        public readonly ?int   $height = null,
14
        public readonly bool   $padding = false
15
    ) {
16
        $this->validate();
17
    }
18
19
20
    public function extension(): ?string
21
    {
22
        return null;
23
    }
24
25
    private function validate(): void
26
    {
27
        $this->validateName();
28
    }
29
30
    private function validateName(): void
31
    {
32
        if (is_numeric($this->name)) {
33
            throw new Exception(
34
                "Style name [$this->name] is numeric. please use string name for your style"
35
            );
36
        }
37
    }
38
}
39