SiteFilter::sublink()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
c 0
b 0
f 0
nc 2
nop 2
dl 0
loc 12
rs 10
1
<?php
2
3
namespace Lepton\Controller;
4
5
use Lepton\Core\Application;
6
7
class SiteFilter
8
{
9
    public function url($string)
10
    {
11
        return Application::getDir()."/".$string;
12
    }
13
14
15
    public function sublink($url, $tocheck)
16
    {
17
        $url = str_replace(Application::getDir(), "", $url);
18
        $tocheck = str_replace(Application::getDir(), "", $tocheck);
19
20
        $url = str_replace(Application::$controller, "", $url);
21
        $tocheck = str_replace(Application::$controller, "", $tocheck);
22
23
        $url = trim(str_replace("//", "", $url), "/");
24
        $tocheck = trim(str_replace("//", "", $tocheck), "/");
25
26
        return str_starts_with($tocheck, $url) && $url != "";
27
    }
28
29
30
    public function query_count($query){
31
        return $query->count();
32
    }
33
34
    public function to_json($elements)
35
    {
36
        return json_encode($elements);
37
    }
38
39
    public function htmlquotes($element)
40
    {
41
        return htmlspecialchars($element);
42
    }
43
44
}
45