Completed
Push — master ( f465ea...00f0fe )
by Melech
07:15
created

Helpers   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getEntityParam() 0 3 1
A getEntityPath() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Valkyrja Framework package.
7
 *
8
 * (c) Melech Mizrachi <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Valkyrja\Routing\Support;
15
16
/**
17
 * Class Helpers.
18
 *
19
 * @author Melech Mizrachi
20
 */
21
class Helpers
22
{
23
    /**
24
     * Get an entity param for a route.
25
     *
26
     * @param string $param  The param name
27
     * @param string $entity The entity class
28
     *
29
     * @return string
30
     */
31
    public static function getEntityParam(string $param, string $entity): string
32
    {
33
        return "{$param}@{$entity}";
34
    }
35
36
    /**
37
     * Get an entity path for a route.
38
     *
39
     * @param string $param  The param name
40
     * @param string $entity The entity class
41
     * @param string $regex  The regex
42
     *
43
     * @return string
44
     */
45
    public static function getEntityPath(string $param, string $entity, string $regex): string
46
    {
47
        $entityRouteParam = static::getEntityParam($param, $entity);
48
49
        return "/{{$entityRouteParam}:{$regex}}";
50
    }
51
}
52