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

RequestParser   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 13.79 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 4
loc 29
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B getNotConvertedLinks() 4 23 4

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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