Failed Conditions
Push — experimental/3.1 ( 7af380...69f38c )
by chihiro
29s
created

UsePointToCustomerPurchaseProcessor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 13 3
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) {
23
            return ProcessResult::success();
24
        }
25
        if ($Customer->getPoint() < $Order->getUsePoint()) {
26
            return ProcessResult::error('利用ポイントが所有ポイントを上回っています.');
27
        }
28
        $Customer->setPoint($Customer->getPoint() + $Order->getUsePoint() * -1);
29
        return ProcessResult::success();
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
30
    }
31
}
32