TradelawController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 56
loc 56
ccs 24
cts 24
cp 1
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 3 3 1
A index() 47 47 3

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
 * This file is part of EC-CUBE
4
 *
5
 * Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved.
6
 *
7
 * http://www.lockon.co.jp/
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation; either version 2
12
 * of the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
 */
23
24
25
namespace Eccube\Controller\Admin\Setting\Shop;
26
27
use Eccube\Application;
28
use Eccube\Controller\AbstractController;
29
use Eccube\Event\EccubeEvents;
30
use Eccube\Event\EventArgs;
31
use Symfony\Component\HttpFoundation\Request;
32
33 View Code Duplication
class TradelawController extends AbstractController
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in 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...
introduced by
Missing class doc comment
Loading history...
34
{
35
    public $form;
36
37
    public function __construct()
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
38
    {
39
    }
40
41 3
    public function index(Application $app, Request $request)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
42
    {
43 3
        $Help = $app['eccube.repository.help']->get();
44
45 3
        $builder = $app['form.factory']
46 3
            ->createBuilder('tradelaw', $Help);
47
48 3
        $event = new EventArgs(
49
            array(
50 3
                'builder' => $builder,
51 3
                'Help' => $Help,
52
            ),
53
            $request
54
        );
55 3
        $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_SETTING_SHOP_TRADE_LAW_INDEX_INITIALIZE, $event);
56
57 3
        $form = $builder->getForm();
58
59 3
        if ('POST' === $app['request']->getMethod()) {
60 2
            $form->handleRequest($app['request']);
61 2
            if ($form->isValid()) {
62 1
                $Help = $form->getData();
63 1
                $app['orm.em']->persist($Help);
64
65 1
                $app['orm.em']->flush();
66
67 1
                $event = new EventArgs(
68
                    array(
69 1
                        'form' => $form,
70 1
                        'Help' => $Help,
71
                    ),
72
                    $request
73
                );
74 1
                $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_SETTING_SHOP_TRADE_LAW_INDEX_COMPLETE, $event);
75
76 1
                $app->addSuccess('admin.register.complete', 'admin');
77
78 1
                return $app->redirect($app->url('admin_setting_shop_tradelaw'));
79
            } else {
80 1
                $app->addError('admin.register.failed', 'admin');
81
            }
82
        }
83
84 2
        return $app->render('Setting/Shop/tradelaw.twig', array(
85 2
            'form' => $form->createView(),
86
        ));
87
    }
88
}
89