Completed
Push — master ( bd4c23...b341c0 )
by Filipe
10:29
created

FullUrlTransformer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 20
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A transform() 0 8 2
1
<?php
2
3
/**
4
 * This file is part of slick/mvc package
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Slick\Mvc\Service\UriGenerator\Transformer;
11
12
use Psr\Http\Message\UriInterface;
13
use Slick\Mvc\Http\UrlRewriter\Uri;
14
use Slick\Mvc\Service\UriGenerator\LocationTransformerInterface;
15
16
/**
17
 * Full URL Transformer
18
 *
19
 * @package Slick\Mvc\Service\UriGenerator\Transformer
20
 * @author  Filipe Silva <[email protected]>
21
 */
22
class FullUrlTransformer extends AbstractLocationTransformer implements
23
    LocationTransformerInterface
24
{
25
    /**
26
     * Tries to transform the provided location data into a server URI
27
     *
28
     * @param string $location Location name, path or identifier
29
     * @param array $options Filter options
30
     *
31
     * @return UriInterface|null
32
     */
33
    public function transform($location, array $options = [])
34
    {
35
        $regexp = '/((https?\:|\/\/).*)/i';
36
        if (preg_match($regexp, $location)) {
37
            return new Uri($location);
38
        }
39
        return null;
40
    }
41
}