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

Style   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 27
rs 10
c 1
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A validateName() 0 5 2
A validate() 0 3 1
A extension() 0 3 1
A __construct() 0 7 1
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