Completed
Pull Request — experimental/3.1 (#2154)
by Kentaro
448:33 queued 441:10
created

OrderDetailCollection::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
ccs 2
cts 2
cp 1
crap 1
1
<?php
2
3
namespace Eccube\Service\Calculator;
4
5
use Eccube\Entity\Order;
6
use Eccube\Entity\OrderDetail;
7
8
class OrderDetailCollection extends \ArrayIterator
0 ignored issues
show
introduced by
Missing class doc comment
Loading history...
9
{
10 12
    public function __construct($OrderDetails, $flags = 0)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
11
    {
12
        // $OrderDetails が Collection だったら toArray(); する
13 12
        parent::__construct($OrderDetails, $flags);
14
    }
15
16
    // 明細種別ごとに返すメソッド作る
17 1
    public function getProductClasses()
0 ignored issues
show
introduced by
You must use "/**" style comments for a function comment
Loading history...
18
    {
19 1
        return new self(array_filter(
20 1
            $this->getArrayCopy(),
21
            function ($OrderDetail) {
22 1
                if ($OrderDetail->getProductClass()) {
23 1
                    return true;
24
                }
25 1
                return false;
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
26 1
            }
27
        ));
28
    }
29
30
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$productName" missing
Loading history...
31
     * 同名の明細が存在するかどうか.
32
     *
33
     * TODO 暫定対応. 本来は明細種別でチェックする.
34
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
35 12
    public function hasProductByName($productName)
36
    {
37 12
        $OrderDetails = array_filter($this->getArrayCopy(),
38 12
                                     function ($OrderDetail) use ($productName) {
39 12
                                         return $OrderDetail->getProductName() == $productName;
40 12
                                     });
41 12
        return !empty($OrderDetails);
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
42
    }
43
    // map, filter, reduce も実装したい
44
}
45