Failed Conditions
Pull Request — experimental/3.1 (#2624)
by Kentaro
07:07
created

UsePointToCustomerPurchaseProcessor   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 10 2
1
<?php
2
3
namespace Eccube\Service\PurchaseFlow\Processor;
4
5
use Eccube\Entity\ItemHolderInterface;
6
use Eccube\Service\PurchaseFlow\PurchaseContext;
7
use Eccube\Service\PurchaseFlow\PurchaseProcessor;
8
use Eccube\Service\PurchaseFlow\ProcessResult;
9
10
/**
11
 * 利用ポイントの減算処理
12
 */
13
class UsePointToCustomerPurchaseProcessor implements PurchaseProcessor
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18
    public function process(ItemHolderInterface $itemHolder, PurchaseContext $context)
19
    {
20
        $Order = $itemHolder;
21
        $Customer = $context->getUser();
22
        if ($Customer->getPoint() < $Order->getUsePoint()) {
23
            return ProcessResult::error('利用ポイントが所有ポイントを上回っています.');
24
        }
25
        $Customer->setPoint($Customer->getPoint() + $Order->getUsePoint() * -1);
26
        return ProcessResult::success();
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
27
    }
28
}
29