Completed
Push — master ( 88258b...584969 )
by
unknown
52:44
created

OldOptionsRouteOptionsResolver   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 50 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 15
loc 30
c 1
b 0
f 0
wmc 5
lcom 0
cbo 2
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B resolve() 15 24 5

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
namespace OroCRM\Bundle\MagentoBundle\Routing;
4
5
use Symfony\Component\Routing\Route;
6
7
use Oro\Component\Routing\Resolver\RouteCollectionAccessor;
8
use Oro\Component\Routing\Resolver\RouteOptionsResolverInterface;
9
10
/**
11
 * As FOSRestBundle v1.7.1 generates a plural path for OPTIONS routes,
12
 * we need to add a single path to avoid BC break.
13
 * The single path is marked as deprecated.
14
 *
15
 * @deprecated since 1.8. Will be removed in 2.0
16
 */
17
class OldOptionsRouteOptionsResolver implements RouteOptionsResolverInterface
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function resolve(Route $route, RouteCollectionAccessor $routes)
23
    {
24 View Code Duplication
        if ($route->getPath() === '/magento/order/view/{id}') {
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...
25
            $singleRoute = $routes->cloneRoute($route);
26
            $singleRoute->setPath('/magentoorder/view/{id}');
27
            $routes->append('orocrm_magentoorder_view', $singleRoute);
28
        }
29
30
        if (!in_array('GET', $route->getMethods(), true)) {
31
            return;
32
        }
33
34 View Code Duplication
        if ($route->getPath() === '/api/rest/{version}/carts/{id}.{_format}') {
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...
35
            $singleRoute = $routes->cloneRoute($route);
36
            $singleRoute->setPath('/api/rest/{version}/magentocarts/{id}.{_format}');
37
            $routes->append('oro_api_get_magentocarts', $singleRoute);
38
        }
39
40 View Code Duplication
        if ($route->getPath() === '/api/rest/{version}/orders/{id}.{_format}') {
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...
41
            $singleRoute = $routes->cloneRoute($route);
42
            $singleRoute->setPath('/api/rest/{version}/magentoorders/{id}.{_format}');
43
            $routes->append('oro_api_get_magentoorders', $singleRoute);
44
        }
45
    }
46
}
47