Completed
Push — master ( 692aa1...25e5a7 )
by Paweł
60:22
created

RequestParser::getNotConvertedLinks()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 23
Code Lines 15

Duplication

Lines 4
Ratio 17.39 %

Importance

Changes 0
Metric Value
dl 4
loc 23
rs 8.7972
c 0
b 0
f 0
cc 4
eloc 15
nc 4
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Superdesk Web Publisher Core Bundle.
7
 *
8
 * Copyright 2016 Sourcefabric z.u. and contributors.
9
 *
10
 * For the full copyright and license information, please see the
11
 * AUTHORS and LICENSE files distributed with this source code.
12
 *
13
 * @copyright 2016 Sourcefabric z.ú
14
 * @license http://www.superdesk.org/license
15
 */
16
17
namespace SWP\Component\Common\Request;
18
19
final class RequestParser implements RequestParserInterface
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public static function getNotConvertedLinks(array $requestLinks)
25
    {
26
        $links = [];
27
        foreach ($requestLinks as $idx => $link) {
28
            if (is_string($link)) {
29
                $linkParams = explode(';', trim($link));
30
                $resourceType = null;
31 View Code Duplication
                if (count($linkParams) > 1) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
32
                    $resourceType = trim(preg_replace('/<|>/', '', $linkParams[1]));
33
                    $resourceType = str_replace('"', '', str_replace('rel=', '', $resourceType));
34
                }
35
                $resource = array_shift($linkParams);
36
                $resource = preg_replace('/<|>/', '', $resource);
37
38
                $links[] = [
39
                    'resource' => $resource,
40
                    'resourceType' => $resourceType,
41
                ];
42
            }
43
        }
44
45
        return $links;
46
    }
47
}
48