Passed
Pull Request — main (#57)
by Andrey
16:09
created

Deprecation::getDeprecationClassBasename()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Helldar\Support\Traits;
4
5
use Helldar\Support\Facades\Instance;
6
7
trait Deprecation
8
{
9
    protected static function deprecationNamespace(string $message = null, ...$args): void
10
    {
11
        static::deprecation(
12
            'The namespace will be changed from %s to \Helldar\Support\Facades\Helpers\%s.',
13
            static::getDeprecationClassBasename(),
14
            static::getDeprecationClassBasename()
15
        );
16
17
        if (! empty($message)) {
18
            static::deprecation($message, ...$args);
19
        }
20
    }
21
22
    protected static function deprecatedClass(): void
23
    {
24
        static::deprecation('The %s class has been deprecated and will be removed.', static::getDeprecationNamespace());
25
    }
26
27
    protected static function getDeprecationNamespace(): string
28
    {
29
        return static::class;
30
    }
31
32
    protected static function getDeprecationClassBasename(): string
33
    {
34
        return Instance::basename(
35
            static::getDeprecationNamespace()
36
        );
37
    }
38
39
    protected static function deprecation(string $message, ...$args): void
40
    {
41
        trigger_deprecation('andrey-helldar/support', '2.0', $message, ...$args);
42
    }
43
}
44