Failed Conditions
Push — experimental/3.1 ( 3d2ede...2919b9 )
by Yangsin
28:59
created

CustomerAddressRepository::delete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
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\Repository;
26
27
use Doctrine\DBAL\Exception\DriverException;
28
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
29
use Eccube\Annotation\Repository;
30
31
/**
32
 * CustomerAddressRepository
33
 *
34
 * This class was generated by the Doctrine ORM. Add your own custom
35
 * repository methods below.
36
 *
37
 * @Repository
38
 */
39
class CustomerAddressRepository extends AbstractRepository
40
{
41
    /**
42
     * @deprecated 呼び出し元で制御する
43
     * @param \Eccube\Entity\Customer $Customer
44
     * @param null $id
0 ignored issues
show
introduced by
Expected 20 spaces after parameter type; 1 found
Loading history...
45
     * @return \Eccube\Entity\CustomerAddress|mixed
46
     * @throws \Doctrine\ORM\NoResultException
47
     * @throws \Doctrine\ORM\NonUniqueResultException
48
     */
49 6
    public function findOrCreateByCustomerAndId(\Eccube\Entity\Customer $Customer, $id = null)
50
    {
51 6
        if (!$id) {
52 3
            $CustomerAddress = new \Eccube\Entity\CustomerAddress();
53 3
            $CustomerAddress->setCustomer($Customer);
54
        } else {
55 4
            $qb = $this->createQueryBuilder('od')
56 4
                ->andWhere('od.Customer = :Customer AND od.id = :id')
57 4
                ->setParameters(array(
58 4
                    'Customer' => $Customer,
59 4
                    'id' => $id,
60
                ));
61
62
            $CustomerAddress = $qb
63 4
                ->getQuery()
64 4
                ->getSingleResult();
65
        }
66
67 5
        return $CustomerAddress;
68
    }
69
70
    /**
71
     * お届け先を削除します.
72
     *
73
     * @param \Eccube\Entity\CustomerAddress $CustomerAddress
74
     */
75 2
    public function delete($CustomerAddress)
76
    {
77 2
        $em = $this->getEntityManager();
78 2
        $em->remove($CustomerAddress);
79 2
        $em->flush($CustomerAddress);
80
    }
81
}
82