Failed Conditions
Branch improve/CsvImportControllerTes... (5a2f92)
by Kentaro
09:12
created

WithdrawController::index()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 39
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 5.7283

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 39
ccs 9
cts 13
cp 0.6923
rs 8.439
cc 5
eloc 19
nc 4
nop 2
crap 5.7283
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\Mypage;
26
27
use Eccube\Application;
28
use Eccube\Controller\AbstractController;
29
use Eccube\Util\Str;
30
use Eccube\Common\Constant;
31
use Symfony\Component\HttpFoundation\Request;
32
33
class WithdrawController extends AbstractController
0 ignored issues
show
introduced by
Missing class doc comment
Loading history...
34
{
35
36
    /**
37
     * Index
38
     *
39
     * @param Application $app
40
     * @param Request $request
0 ignored issues
show
introduced by
Expected 5 spaces after parameter type; 1 found
Loading history...
41
     * @return \Symfony\Component\HttpFoundation\Response
42
     */
43 3
    public function index(Application $app, Request $request)
44
    {
45
        /* @var $form \Symfony\Component\Form\FormInterface */
46
        $form = $app->form()->getForm();
47
        $form->handleRequest($request);
48
49
        if ($form->isSubmitted() && $form->isValid()) {
50 2
            switch ($request->get('mode')) {
51 2
                case 'confirm':
52 1
                    return $app->renderView('Mypage/withdraw_confirm.twig', array(
53 1
                        'form' => $form->createView(),
54
                    ));
55
56 1
                case 'complete':
57
                    /* @var $Customer \Eccube\Entity\Customer */
58
                    $Customer = $app->user();
59
60
                    // 会員削除
61
                    $email = $Customer->getEmail();
62
                    // メールアドレスにダミーをセット
63
                    $Customer->setEmail(Str::random(60) . '@dummy.dummy');
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
64
                    $Customer->setDelFlg(Constant::ENABLED);
65
66
                    $app['orm.em']->flush();
67
68
                    // メール送信
69
                    $app['eccube.service.mail']->sendCustomerWithdrawMail($Customer, $email);
70
71
                    // ログアウト
72
                    $this->getSecurity($app)->setToken(null);
73
74
                    return $app->redirect($app->url('mypage_withdraw_complete'));
75
            }
76
        }
77
78 1
        return $app->renderView('Mypage/withdraw.twig', array(
79 1
            'form' => $form->createView(),
80
        ));
81 3
    }
82
83
    /**
84
     * Complete
85
     *
86
     * @param Application $app
87
     * @param Request $request
0 ignored issues
show
introduced by
Expected 5 spaces after parameter type; 1 found
Loading history...
88
     * @return \Symfony\Component\HttpFoundation\Response
89
     */
90 1
    public function complete(Application $app, Request $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
91
    {
92
        return $app->renderView('Mypage/withdraw_complete.twig');
93 1
    }
94
}
95