Helper   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A idPrefixIncludedInAttachmentId() 0 6 1
A stripSiteIdPrefixFromAttachmentId() 0 3 1
1
<?php # -*- coding: utf-8 -*-
2
declare(strict_types=1);
3
4
namespace MultisiteGlobalMedia;
5
6
/**
7
 * Class CompareHelper
8
 */
9
trait Helper
10
{
11
    /**
12
     * Check if the given site Id prefix exists into the give attachment id
13
     *
14
     * @param int $attachmentId
15
     * @param string $siteIdPrefix
16
     * @return bool
17
     */
18
    private function idPrefixIncludedInAttachmentId(
19
        int $attachmentId,
20
        string $siteIdPrefix
21
    ): bool {
22
23
        return false !== strpos((string)$attachmentId, $siteIdPrefix);
24
    }
25
26
    /**
27
     * Remove the site Id prefix from the give attachment id
28
     *
29
     * @param string $idPrefix
30
     * @param int $attachmentId
31
     * @return int
32
     */
33
    private function stripSiteIdPrefixFromAttachmentId(string $idPrefix, int $attachmentId): int
34
    {
35
        return (int)str_replace($idPrefix, '', (string)$attachmentId);
36
    }
37
}
38