Issues (879)

Bundle/ShopBundle/Order/OrderNumberGenerator.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: jenny
5
 * Date: 29.12.16
6
 * Time: 09:36
7
 */
8
9
namespace Enhavo\Bundle\ShopBundle\Order;
10
11
use Enhavo\Bundle\ShopBundle\Repository\OrderRepository;
12
13
class OrderNumberGenerator implements OrderNumberGeneratorInterface
14
{
15
    public function __construct(
16
        private OrderRepository $repository)
17
    {
18
    }
19
20
    public function generate()
21
    {
22
        $order = $this->repository->findLastNumber();
23
24
        if (count($order)) {
0 ignored issues
show
$order of type Enhavo\Bundle\ShopBundle\Model\OrderInterface is incompatible with the type Countable|array expected by parameter $value of count(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

24
        if (count(/** @scrutinizer ignore-type */ $order)) {
Loading history...
25
            $number = $order[0]->getNumber();
26
            if($number !== null) {
27
                $number++;
28
                return $number;
29
            }
30
        }
31
32
        return 1;
33
    }
34
}
35