Completed
Push — master ( 7e2127...77c655 )
by Marcus
04:10
created

AttributeSetBunchProcessor::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 18
ccs 0
cts 18
cp 0
rs 10
cc 1
nc 1
nop 8
crap 2

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
/**
4
 * TechDivision\Import\Attribute\Services\AttributeSetBunchProcessor
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2019 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/techdivision/import-attribute-set
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Attribute\Set\Services;
22
23
use TechDivision\Import\Actions\ActionInterface;
24
use TechDivision\Import\Loaders\LoaderInterface;
0 ignored issues
show
Bug introduced by
The type TechDivision\Import\Loaders\LoaderInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
25
use TechDivision\Import\Connection\ConnectionInterface;
26
use TechDivision\Import\Repositories\EavAttributeSetRepositoryInterface;
27
use TechDivision\Import\Attribute\Set\Repositories\EntityAttributeRepositoryInterface;
28
use TechDivision\Import\Attribute\Set\Repositories\EavAttributeGroupRepositoryInterface;
29
30
/**
31
 * The attribute set bunch processor implementation.
32
 *
33
 * @author    Tim Wagner <[email protected]>
34
 * @copyright 2019 TechDivision GmbH <[email protected]>
35
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
36
 * @link      https://github.com/techdivision/import-attribute-set
37
 * @link      http://www.techdivision.com
38
 */
39
class AttributeSetBunchProcessor implements AttributeSetBunchProcessorInterface
40
{
41
42
    /**
43
     * A connection to use.
44
     *
45
     * @var \TechDivision\Import\Connection\ConnectionInterface
46
     */
47
    protected $connection;
48
49
    /**
50
     * The EAV attribute set repository instance.
51
     *
52
     * @var \TechDivision\Import\Repositories\EavAttributeSetRepositoryInterface
53
     */
54
    protected $eavAttributeSetRepository;
55
56
    /**
57
     * The EAV attribute set repository instance.
58
     *
59
     * @var \TechDivision\Import\Attribute\Set\Repositories\EavAttributeGroupRepositoryInterface
60
     */
61
    protected $eavAttributeGroupRepository;
62
63
    /**
64
     * The EAV entity attribute repository instance.
65
     *
66
     * @var \TechDivision\Import\Attribute\Set\Repositories\EntityAttributeRepositoryInterface
67
     */
68
    protected $attributeOptionRepository;
69
70
    /**
71
     * The attribute set action instance.
72
     *
73
     * @var \TechDivision\Import\Actions\ActionInterface
74
     */
75
    protected $eavAttributeSetAction;
76
77
    /**
78
     * The attribute group action instance.
79
     *
80
     * @var \TechDivision\Import\Actions\ActionInterface
81
     */
82
    protected $eavAttributeGroupAction;
83
84
    /**
85
     * The entity attribute action instance.
86
     *
87
     * @var \TechDivision\Import\Actions\ActionInterface
88
     */
89
    protected $entityAttributeAction;
90
91
    /**
92
     * The raw entity loader instance.
93
     *
94
     * @var \TechDivision\Import\Loaders\LoaderInterface
95
     */
96
    protected $rawEntityLoader;
97
98
    /**
99
     * Initialize the processor with the necessary repository and action instances.
100
     *
101
     * @param \TechDivision\Import\Connection\ConnectionInterface                                  $connection                  The connection to use
102
     * @param \TechDivision\Import\Repositories\EavAttributeSetRepositoryInterface                 $eavAttributeSetRepository   The EAV attribute set repository instance
103
     * @param \TechDivision\Import\Attribute\Set\Repositories\EavAttributeGroupRepositoryInterface $eavAttributeGroupRepository The EAV attribute group repository instance
104
     * @param \TechDivision\Import\Attribute\Set\Repositories\EntityAttributeRepositoryInterface   $entityAttributeRepository   The EAV attribute option repository instance
105
     * @param \TechDivision\Import\Actions\ActionInterface                                         $eavAttributeSetAction       The EAV attribute set action instance
106
     * @param \TechDivision\Import\Actions\ActionInterface                                         $eavAttributeGroupAction     The EAV attribute gropu action instance
107
     * @param \TechDivision\Import\Actions\ActionInterface                                         $entityAttributeAction       The entity attribute action instance
108
     * @param \TechDivision\Import\Loaders\LoaderInterface                                         $rawEntityLoader             The raw entity loader instance
109
     */
110
    public function __construct(
111
        ConnectionInterface $connection,
112
        EavAttributeSetRepositoryInterface $eavAttributeSetRepository,
113
        EavAttributeGroupRepositoryInterface $eavAttributeGroupRepository,
114
        EntityAttributeRepositoryInterface $entityAttributeRepository,
115
        ActionInterface $eavAttributeSetAction,
116
        ActionInterface $eavAttributeGroupAction,
117
        ActionInterface $entityAttributeAction,
118
        LoaderInterface $rawEntityLoader
119
    ) {
120
        $this->setConnection($connection);
121
        $this->setEavAttributeSetRepository($eavAttributeSetRepository);
122
        $this->setEavAttributeGroupRepository($eavAttributeGroupRepository);
123
        $this->setEntityAttributeRepository($entityAttributeRepository);
124
        $this->setEavAttributeSetAction($eavAttributeSetAction);
125
        $this->setEavAttributeGroupAction($eavAttributeGroupAction);
126
        $this->setEntityAttributeAction($entityAttributeAction);
127
        $this->setRawEntityLoader($rawEntityLoader);
128
    }
129
130
    /**
131
     * Set's the raw entity loader instance.
132
     *
133
     * @param \TechDivision\Import\Loaders\LoaderInterface $rawEntityLoader The raw entity loader instance to set
134
     *
135
     * @return void
136
     */
137
    public function setRawEntityLoader(LoaderInterface $rawEntityLoader)
138
    {
139
        $this->rawEntityLoader = $rawEntityLoader;
140
    }
141
142
    /**
143
     * Return's the raw entity loader instance.
144
     *
145
     * @return \TechDivision\Import\Loaders\LoaderInterface The raw entity loader instance
146
     */
147
    public function getRawEntityLoader()
148
    {
149
        return $this->rawEntityLoader;
150
    }
151
152
    /**
153
     * Set's the passed connection.
154
     *
155
     * @param \TechDivision\Import\Connection\ConnectionInterface $connection The connection to set
156
     *
157
     * @return void
158
     */
159
    public function setConnection(ConnectionInterface $connection)
160
    {
161
        $this->connection = $connection;
162
    }
163
164
    /**
165
     * Return's the connection.
166
     *
167
     * @return \TechDivision\Import\Connection\ConnectionInterface The connection instance
168
     */
169
    public function getConnection()
170
    {
171
        return $this->connection;
172
    }
173
174
    /**
175
     * Turns off autocommit mode. While autocommit mode is turned off, changes made to the database via the PDO
176
     * object instance are not committed until you end the transaction by calling ProductProcessor::commit().
177
     * Calling ProductProcessor::rollBack() will roll back all changes to the database and return the connection
178
     * to autocommit mode.
179
     *
180
     * @return boolean Returns TRUE on success or FALSE on failure
181
     * @link http://php.net/manual/en/pdo.begintransaction.php
182
     */
183
    public function beginTransaction()
184
    {
185
        return $this->connection->beginTransaction();
186
    }
187
188
    /**
189
     * Commits a transaction, returning the database connection to autocommit mode until the next call to
190
     * ProductProcessor::beginTransaction() starts a new transaction.
191
     *
192
     * @return boolean Returns TRUE on success or FALSE on failure
193
     * @link http://php.net/manual/en/pdo.commit.php
194
     */
195
    public function commit()
196
    {
197
        return $this->connection->commit();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->connection->commit() returns the type void which is incompatible with the documented return type boolean.
Loading history...
Bug introduced by
Are you sure the usage of $this->connection->commit() targeting TechDivision\Import\Conn...tionInterface::commit() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
198
    }
199
200
    /**
201
     * Rolls back the current transaction, as initiated by ProductProcessor::beginTransaction().
202
     *
203
     * If the database was set to autocommit mode, this function will restore autocommit mode after it has
204
     * rolled back the transaction.
205
     *
206
     * Some databases, including MySQL, automatically issue an implicit COMMIT when a database definition
207
     * language (DDL) statement such as DROP TABLE or CREATE TABLE is issued within a transaction. The implicit
208
     * COMMIT will prevent you from rolling back any other changes within the transaction boundary.
209
     *
210
     * @return boolean Returns TRUE on success or FALSE on failure
211
     * @link http://php.net/manual/en/pdo.rollback.php
212
     */
213
    public function rollBack()
214
    {
215
        return $this->connection->rollBack();
216
    }
217
218
    /**
219
     * Set's the attribute set repository instance.
220
     *
221
     * @param \TechDivision\Import\Repositories\EavAttributeSetRepositoryInterface $eavAttributeSetRepository The attribute set repository instance
222
     *
223
     * @return void
224
     */
225
    public function setEavAttributeSetRepository(EavAttributeSetRepositoryInterface $eavAttributeSetRepository)
226
    {
227
        $this->eavAttributeSetRepository = $eavAttributeSetRepository;
228
    }
229
230
    /**
231
     * Return's the attribute set repository instance.
232
     *
233
     * @return \TechDivision\Import\Repositories\EavAttributeSetRepositoryInterface The attribute set repository instance
234
     */
235
    public function getEavAttributeSetRepository()
236
    {
237
        return $this->eavAttributeSetRepository;
238
    }
239
240
    /**
241
     * Set's the attribute group repository instance.
242
     *
243
     * @param \TechDivision\Import\Attribute\Set\Repositories\EavAttributeGroupRepositoryInterface $eavAttributeGroupRepository The attribute group repository instance
244
     *
245
     * @return void
246
     */
247
    public function setEavAttributeGroupRepository(EavAttributeGroupRepositoryInterface $eavAttributeGroupRepository)
248
    {
249
        $this->eavAttributeGroupRepository = $eavAttributeGroupRepository;
250
    }
251
252
    /**
253
     * Return's the attribute group repository instance.
254
     *
255
     * @return \TechDivision\Import\Attribute\Set\Repositories\EavAttributeGroupRepositoryInterface The attribute group repository instance
256
     */
257
    public function getEavAttributeGroupRepository()
258
    {
259
        return $this->eavAttributeGroupRepository;
260
    }
261
262
    /**
263
     * Set's the entity attribute repository instance.
264
     *
265
     * @param \TechDivision\Import\Attribute\Set\Repositories\EntityAttributeRepositoryInterface $entityAttributeRepository The entity attribute repository instance
266
     *
267
     * @return void
268
     */
269
    public function setEntityAttributeRepository(EntityAttributeRepositoryInterface $entityAttributeRepository)
270
    {
271
        $this->entityAttributeRepository = $entityAttributeRepository;
0 ignored issues
show
Bug Best Practice introduced by
The property entityAttributeRepository does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
272
    }
273
274
    /**
275
     * Return's the entity attribute repository instance.
276
     *
277
     * @return \TechDivision\Import\Attribute\Set\Repositories\EntityAttributeRepositoryInterface The entity attribute repository instance
278
     */
279
    public function getEntityAttributeRepository()
280
    {
281
        return $this->entityAttributeRepository;
282
    }
283
284
    /**
285
     * Set's the EAV attribute set action instance.
286
     *
287
     * @param \TechDivision\Import\Actions\ActionInterface $eavAttributeSetAction The attribute set action instance
288
     *
289
     * @return void
290
     */
291
    public function setEavAttributeSetAction(ActionInterface $eavAttributeSetAction)
292
    {
293
        $this->eavAttributeSetAction = $eavAttributeSetAction;
294
    }
295
296
    /**
297
     * Return's the attribute set action instance.
298
     *
299
     * @return \TechDivision\Import\Actions\ActionInterface The attribute set action instance
300
     */
301
    public function getEavAttributeSetAction()
302
    {
303
        return $this->eavAttributeSetAction;
304
    }
305
306
    /**
307
     * Set's the EAV attribute group action instance.
308
     *
309
     * @param \TechDivision\Import\Actions\ActionInterface $eavAttributeGroupAction The attribute gropu action instance
310
     *
311
     * @return void
312
     */
313
    public function setEavAttributeGroupAction(ActionInterface $eavAttributeGroupAction)
314
    {
315
        $this->eavAttributeGroupAction = $eavAttributeGroupAction;
316
    }
317
318
    /**
319
     * Return's the attribute group action instance.
320
     *
321
     * @return \TechDivision\Import\Actions\ActionInterface The attribute group action instance
322
     */
323
    public function getEavAttributeGroupAction()
324
    {
325
        return $this->eavAttributeGroupAction;
326
    }
327
328
    /**
329
     * Set's the entity attribute action instance.
330
     *
331
     * @param \TechDivision\Import\Actions\ActionInterface $entityAttributeAction The entity attribute action instance
332
     *
333
     * @return void
334
     */
335
    public function setEntityAttributeAction(ActionInterface $entityAttributeAction)
336
    {
337
        $this->entityAttributeAction = $entityAttributeAction;
338
    }
339
340
    /**
341
     * Return's the entity attribute action instance.
342
     *
343
     * @return \TechDivision\Import\Actions\ActionInterface The entity attribute action instance
344
     */
345
    public function getEntityAttributeAction()
346
    {
347
        return $this->entityAttributeAction;
348
    }
349
350
    /**
351
     * Load's and return's a raw entity without primary key but the mandatory members only and nulled values.
352
     *
353
     * @param string $entityTypeCode The entity type code to return the raw entity for
354
     * @param array  $data           An array with data that will be used to initialize the raw entity with
355
     *
356
     * @return array The initialized entity
357
     */
358
    public function loadRawEntity($entityTypeCode, array $data = array())
359
    {
360
        return $this->getRawEntityLoader()->load($entityTypeCode, $data);
361
    }
362
363
    /**
364
     * Load's and return's the EAV attribute set with the passed entity type code and attribute set name.
365
     *
366
     * @param string $entityTypeCode   The entity type code of the EAV attribute set to load
367
     * @param string $attributeSetName The attribute set name of the EAV attribute set to return
368
     *
369
     * @return array The EAV attribute set
370
     */
371
    public function loadAttributeSetByEntityTypeCodeAndAttributeSetName($entityTypeCode, $attributeSetName)
372
    {
373
        return $this->getEavAttributeSetRepository()->findOneByEntityTypeCodeAndAttributeSetName($entityTypeCode, $attributeSetName);
0 ignored issues
show
Bug introduced by
The method findOneByEntityTypeCodeAndAttributeSetName() does not exist on TechDivision\Import\Repo...eSetRepositoryInterface. ( Ignorable by Annotation )

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

373
        return $this->getEavAttributeSetRepository()->/** @scrutinizer ignore-call */ findOneByEntityTypeCodeAndAttributeSetName($entityTypeCode, $attributeSetName);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
374
    }
375
376
    /**
377
     * Load's and return's the EAV attribute set with the passed entity type ID and attribute set name.
378
     *
379
     * @param string $entityTypeId     The entity type ID of the EAV attribute set to load
380
     * @param string $attributeSetName The attribute set name of the EAV attribute set to return
381
     *
382
     * @return array The EAV attribute set
383
     */
384
    public function loadAttributeSetByEntityTypeIdAndAttributeSetName($entityTypeId, $attributeSetName)
385
    {
386
        return $this->getEavAttributeSetRepository()->findOneByEntityTypeIdAndAttributeSetName($entityTypeId, $attributeSetName);
0 ignored issues
show
Bug introduced by
The method findOneByEntityTypeIdAndAttributeSetName() does not exist on TechDivision\Import\Repo...eSetRepositoryInterface. ( Ignorable by Annotation )

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

386
        return $this->getEavAttributeSetRepository()->/** @scrutinizer ignore-call */ findOneByEntityTypeIdAndAttributeSetName($entityTypeId, $attributeSetName);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
387
    }
388
389
    /**
390
     * Return's the EAV attribute group with the passed entity type code, attribute set and attribute group name.
391
     *
392
     * @param string $entityTypeCode     The entity type code of the EAV attribute group to return
393
     * @param string $attributeSetName   The attribute set name of the EAV attribute group to return
394
     * @param string $attributeGroupName The attribute group name of the EAV attribute group to return
395
     *
396
     * @return array The EAV attribute group
397
     */
398
    public function loadAttributeGroupByEntityTypeCodeAndAttributeSetNameAndAttributeGroupName($entityTypeCode, $attributeSetName, $attributeGroupName)
399
    {
400
        return $this->getEavAttributeGroupRepository()->findOneByEntityTypeCodeAndAttributeSetNameAndAttributeGroupName($entityTypeCode, $attributeSetName, $attributeGroupName);
0 ignored issues
show
Bug introduced by
The method findOneByEntityTypeCodeA...AndAttributeGroupName() does not exist on TechDivision\Import\Attr...roupRepositoryInterface. ( Ignorable by Annotation )

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

400
        return $this->getEavAttributeGroupRepository()->/** @scrutinizer ignore-call */ findOneByEntityTypeCodeAndAttributeSetNameAndAttributeGroupName($entityTypeCode, $attributeSetName, $attributeGroupName);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
401
    }
402
403
    /**
404
     * Returns the EAV entity attributes for the attribute group with the passed ID.
405
     *
406
     * @param integer $attributeGroupId The attribute group ID to load the EAV entity attributes for
407
     *
408
     * @return array|null The EAV attributes with for the passed attribute group ID
409
     */
410
    public function loadEntityAttributesByAttributeGroupId($attributeGroupId)
411
    {
412
        return $this->getEntityAttributeRepository()->findAllByAttributeGroupId($attributeGroupId);
413
    }
414
415
    /**
416
     * Returns the EAV entity attributes for the entity type ID and attribute set with the passed name.
417
     *
418
     * @param integer $entityTypeId     The entity type ID to load the EAV entity attributes for
419
     * @param string  $attributeSetName The attribute set name to return the EAV entity attributes for
420
     *
421
     * @return array|null The EAV entity attributes with for the passed entity type ID and attribute set name
422
     */
423
    public function loadEntityAttributesByEntityTypeIdAndAttributeSetName($entityTypeId, $attributeSetName)
424
    {
425
        return $this->getEntityAttributeRepository()->findAllByEntityTypeIdAndAttributeSetName($entityTypeId, $attributeSetName);
426
    }
427
428
    /**
429
     * Return's the EAV entity attribute with the passed attribute and attribute set ID.
430
     *
431
     * @param integer $attributeId    The ID of the EAV entity attribute's attribute to return
432
     * @param integer $attributeSetId The ID of the EAV entity attribute's attribute set to return
433
     *
434
     * @return array The EAV entity attribute
435
     */
436
    public function loadEntityAttributeByAttributeIdAndAttributeSetId($attributeId, $attributeSetId)
437
    {
438
        return $this->getEntityAttributeRepository()->findOneByAttributeIdAndAttributeSetId($attributeId, $attributeSetId);
0 ignored issues
show
Bug introduced by
The method findOneByAttributeIdAndAttributeSetId() does not exist on TechDivision\Import\Attr...buteRepositoryInterface. ( Ignorable by Annotation )

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

438
        return $this->getEntityAttributeRepository()->/** @scrutinizer ignore-call */ findOneByAttributeIdAndAttributeSetId($attributeId, $attributeSetId);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
439
    }
440
441
    /**
442
     * Return's the attribute groups for the passed attribute set ID, whereas the array
443
     * is prepared with the attribute group names as keys.
444
     *
445
     * @param mixed $attributeSetId The EAV attribute set ID to return the attribute groups for
446
     *
447
     * @return array|boolean The EAV attribute groups for the passed attribute ID
448
     */
449
    public function loadAttributeGroupsByAttributeSetId($attributeSetId)
450
    {
451
        return $this->getEavAttributeGroupRepository()->findAllByAttributeSetId($attributeSetId);
452
    }
453
454
    /**
455
     * Return's the attribute group for the passed attribute set ID and attribute group code.
456
     *
457
     * @param integer $attributeSetId     The EAV attribute set ID to return the attribute group for
458
     * @param string  $attributeGroupCode The EAV attribute group code to load the attribute group for
459
     *
460
     * @return array|boolean The EAV attribute group for the passed attribute set ID and attribute group code
461
     */
462
    public function loadAttributeGroupByAttributeSetIdAndAttributeGroupCode($attributeSetId, $attributeGroupCode)
463
    {
464
        return $this->getEavAttributeGroupRepository()->findOneByAttributeSetIdAndAttributeGroupCode($attributeSetId, $attributeGroupCode);
465
    }
466
467
    /**
468
     * Persist's the passed EAV attribute set data and return's the ID.
469
     *
470
     * @param array       $attributeSet The attribute set data to persist
471
     * @param string|null $name         The name of the prepared statement that has to be executed
472
     *
473
     * @return string The ID of the persisted attribute set
474
     */
475
    public function persistAttributeSet(array $attributeSet, $name = null)
476
    {
477
        return $this->getEavAttributeSetAction()->persist($attributeSet);
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->getEavAttributeSe...>persist($attributeSet) targeting TechDivision\Import\Acti...ionInterface::persist() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Bug Best Practice introduced by
The expression return $this->getEavAttr...>persist($attributeSet) returns the type void which is incompatible with the documented return type string.
Loading history...
478
    }
479
480
    /**
481
     * Persist the passed EAV attribute group.
482
     *
483
     * @param array       $attributeGroup The attribute group to persist
484
     * @param string|null $name           The name of the prepared statement that has to be executed
485
     *
486
     * @return string The ID of the persisted attribute group
487
     */
488
    public function persistAttributeGroup(array $attributeGroup, $name = null)
489
    {
490
        return $this->getEavAttributeGroupAction()->persist($attributeGroup);
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->getEavAttributeGr...ersist($attributeGroup) targeting TechDivision\Import\Acti...ionInterface::persist() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Bug Best Practice introduced by
The expression return $this->getEavAttr...ersist($attributeGroup) returns the type void which is incompatible with the documented return type string.
Loading history...
491
    }
492
493
    /**
494
     * Persist's the passed EAV entity attribute data and return's the ID.
495
     *
496
     * @param array       $entityAttribute The entity attribute data to persist
497
     * @param string|null $name            The name of the prepared statement that has to be executed
498
     *
499
     * @return void
500
     */
501
    public function persistEntityAttribute(array $entityAttribute, $name = null)
502
    {
503
        $this->getEntityAttributeAction()->persist($entityAttribute, $name);
0 ignored issues
show
Unused Code introduced by
The call to TechDivision\Import\Acti...ionInterface::persist() has too many arguments starting with $name. ( Ignorable by Annotation )

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

503
        $this->getEntityAttributeAction()->/** @scrutinizer ignore-call */ persist($entityAttribute, $name);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
504
    }
505
506
    /**
507
     * Delete's the EAV attribute set with the passed attributes.
508
     *
509
     * @param array       $row  The attributes of the EAV attribute group to delete
510
     * @param string|null $name The name of the prepared statement that has to be executed
511
     *
512
     * @return void
513
     */
514
    public function deleteAttributeSet($row, $name = null)
515
    {
516
        $this->getEavAttributeSetAction()->delete($row, $name);
517
    }
518
}
519