SiteFilter   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
eloc 12
c 2
b 0
f 0
dl 0
loc 35
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A url() 0 3 1
A sublink() 0 12 2
A to_json() 0 3 1
A htmlquotes() 0 3 1
A query_count() 0 2 1
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