Passed
Push — master ( 03c468...179943 )
by Darko
11:56
created

ReleaseContext::getLowerReleaseName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Services\Categorization;
4
5
/**
6
 * Value object containing release information for categorization.
7
 */
8
class ReleaseContext
9
{
10
    public function __construct(
11
        public readonly string $releaseName,
12
        public readonly int|string $groupId,
13
        public readonly string $groupName = '',
14
        public readonly string $poster = '',
15
        public readonly bool $categorizeForeign = true,
16
        public readonly bool $catWebDL = true,
17
    ) {}
18
19
    /**
20
     * Get the release name in lowercase for case-insensitive matching.
21
     */
22
    public function getLowerReleaseName(): string
23
    {
24
        return strtolower($this->releaseName);
25
    }
26
27
    /**
28
     * Check if the release name matches a pattern.
29
     */
30
    public function matchesPattern(string $pattern): bool
31
    {
32
        return (bool) preg_match($pattern, $this->releaseName);
33
    }
34
35
    /**
36
     * Check if the release name contains a substring (case-insensitive).
37
     */
38
    public function containsString(string $needle): bool
39
    {
40
        return stripos($this->releaseName, $needle) !== false;
41
    }
42
43
    /**
44
     * Check if the group name matches a pattern.
45
     */
46
    public function groupMatchesPattern(string $pattern): bool
47
    {
48
        return (bool) preg_match($pattern, $this->groupName);
49
    }
50
51
    /**
52
     * Check if this release has adult/XXX markers.
53
     */
54
    public function hasAdultMarkers(): bool
55
    {
56
        // Check for explicit XXX markers and common adult keywords
57
        if (preg_match('/\b(XXX|Porn|Anal|Brazzers|BangBros|Bangbros|NaughtyAmerica|RealityKings|Tushy|Vixen|Blacked|OnlyFans|MetArt|JoyMii|Creampie|MP4-XXX|PureTaboo|LadyLyne|TeamSkeet|GirlsWay|EvilAngel|Kink|FakeHub|FakeTaxi|SexArt|Nubiles|Defloration|Deeper|Bellesa|Twistys|Mofos|MissaX|LegalPorno|AnalVids|JAV|Hentai)\b/i', $this->releaseName)) {
58
            return true;
59
        }
60
61
        // Check for adult keywords combined with resolution (likely adult clip)
62
        if (preg_match('/\b(Fuck|Fucked|Fucking|Cock|Dick|Pussy|Cum|Cumshot|Blowjob|Handjob|MILF|Teen|Lesbian|Threesome|Gangbang|Hardcore|Interracial)\b/i', $this->releaseName) &&
63
            preg_match('/\b(720p|1080p|2160p|4k|mp4)\b/i', $this->releaseName)) {
64
            return true;
65
        }
66
67
        return false;
68
    }
69
}
70
71