CombinedProductMandatoryColumnCondition::hasData()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 9
c 0
b 0
f 0
rs 10
cc 3
nc 3
nop 1
1
<?php
2
3
/**
4
 * This file is part of the Spryker Commerce OS.
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
declare(strict_types = 1);
9
10
namespace Pyz\Zed\DataImport\Business\CombinedProduct\DataSet;
11
12
use Pyz\Zed\DataImport\Business\Model\DataSet\DataSetConditionInterface;
13
use Spryker\Zed\DataImport\Business\Model\DataSet\DataSetInterface;
14
15
abstract class CombinedProductMandatoryColumnCondition implements DataSetConditionInterface
16
{
17
    /**
18
     * Specification:
19
     * - Returns a list of columns.
20
     *
21
     * @return array<string>
22
     */
23
    abstract protected function getMandatoryColumns(): array;
24
25
    /**
26
     * Specification:
27
     * - Returns true if at least 1 mandatory column contains data.
28
     *
29
     * @param \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetInterface $dataSet
30
     *
31
     * @return bool
32
     */
33
    final public function hasData(DataSetInterface $dataSet): bool
34
    {
35
        foreach ($this->getMandatoryColumns() as $mandatoryColumn) {
36
            if (!empty($dataSet[$mandatoryColumn])) {
37
                return true;
38
            }
39
        }
40
41
        return false;
42
    }
43
}
44