SiteHelper::resolveSiteId()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 0
cts 7
cp 0
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
crap 6
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://github.com/flipbox/spark/blob/master/LICENSE
6
 * @link       https://github.com/flipbox/spark
7
 */
8
9
namespace flipbox\spark\helpers;
10
11
use Craft;
12
13
/**
14
 * @author Flipbox Factory <[email protected]>
15
 * @since 1.0.0
16
 */
17
class SiteHelper
18
{
19
20
    /**
21
     * @param int|null $siteId
22
     * @return int
23
     */
24
    public static function resolveSiteId(int $siteId = null): int
25
    {
26
27
        if (is_null($siteId)) {
28
            $siteId = Craft::$app->getSites()->currentSite->id;
29
        }
30
31
        return $siteId;
32
    }
33
}
34