Passed
Push — 15.x ( f9b626 )
by Tim
04:47
created

CustomerBunchProcessor::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 27
rs 9.8666
cc 1
nc 1
nop 13

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\Customer\Services\CustomerBunchProcessor
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 2018 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-customer
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Customer\Services;
22
23
use TechDivision\Import\Loaders\LoaderInterface;
24
use TechDivision\Import\Actions\ActionInterface;
25
use TechDivision\Import\Connection\ConnectionInterface;
26
use TechDivision\Import\Repositories\EavAttributeRepositoryInterface;
27
use TechDivision\Import\Repositories\EavEntityTypeRepositoryInterface;
28
use TechDivision\Import\Repositories\EavAttributeOptionValueRepositoryInterface;
29
use TechDivision\Import\Customer\Assemblers\CustomerAttributeAssemblerInterface;
30
use TechDivision\Import\Customer\Repositories\CustomerRepositoryInterface;
31
32
/**
33
 * The customer bunch processor implementation.
34
 *
35
 * @author    Tim Wagner <[email protected]>
36
 * @copyright 2018 TechDivision GmbH <[email protected]>
37
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
38
 * @link      https://github.com/techdivision/import-customer
39
 * @link      http://www.techdivision.com
40
 */
41
class CustomerBunchProcessor implements CustomerBunchProcessorInterface
42
{
43
44
    /**
45
     * A PDO connection initialized with the values from the Doctrine EntityManager.
46
     *
47
     * @var \TechDivision\Import\Connection\ConnectionInterface
48
     */
49
    protected $connection;
50
51
    /**
52
     * The repository to access EAV attribute option values.
53
     *
54
     * @var \TechDivision\Import\Repositories\EavAttributeOptionValueRepositoryInterface
55
     */
56
    protected $eavAttributeOptionValueRepository;
57
58
    /**
59
     * The repository to access customer data.
60
     *
61
     * @var \TechDivision\Import\Customer\Repositories\CustomerRepositoryInterface
62
     */
63
    protected $customerRepository;
64
65
    /**
66
     * The repository to access EAV attributes.
67
     *
68
     * @var \TechDivision\Import\Repositories\EavAttributeRepositoryInterface
69
     */
70
    protected $eavAttributeRepository;
71
72
    /**
73
     * The repository to access EAV attributes.
74
     *
75
     * @var \TechDivision\Import\Repositories\EavEntityTypeRepositoryInterface
76
     */
77
    protected $eavEntityTypeRepository;
78
79
    /**
80
     * The action for customer CRUD methods.
81
     *
82
     * @var \TechDivision\Import\Actions\ActionInterface
83
     */
84
    protected $customerAction;
85
86
    /**
87
     * The action for customer varchar attribute CRUD methods.
88
     *
89
     * @var \TechDivision\Import\Actions\ActionInterface
90
     */
91
    protected $customerVarcharAction;
92
93
    /**
94
     * The action for customer text attribute CRUD methods.
95
     *
96
     * @var \TechDivision\Import\Actions\ActionInterface
97
     */
98
    protected $customerTextAction;
99
100
    /**
101
     * The action for customer int attribute CRUD methods.
102
     *
103
     * @var \TechDivision\Import\Actions\ActionInterface
104
     */
105
    protected $customerIntAction;
106
107
    /**
108
     * The action for customer decimal attribute CRUD methods.
109
     *
110
     * @var \TechDivision\Import\Actions\ActionInterface
111
     */
112
    protected $customerDecimalAction;
113
114
    /**
115
     * The action for customer datetime attribute CRUD methods.
116
     *
117
     * @var \TechDivision\Import\Actions\ActionInterface
118
     */
119
    protected $customerDatetimeAction;
120
121
    /**
122
     * The assembler to load the customer attributes with.
123
     *
124
     * @var \TechDivision\Import\Customer\Assemblers\CustomerAttributeAssemblerInterface
125
     */
126
    protected $customerAttributeAssembler;
127
128
    /**
129
     * The raw entity loader instance.
130
     *
131
     * @var \TechDivision\Import\Loaders\LoaderInterface
132
     */
133
    protected $rawEntityLoader;
134
135
    /**
136
     * Initialize the processor with the necessary assembler and repository instances.
137
     *
138
     * @param \TechDivision\Import\Connection\ConnectionInterface                          $connection                        The connection to use
139
     * @param \TechDivision\Import\Customer\Assemblers\CustomerAttributeAssemblerInterface $customerAttributeAssembler        The customer attribute assembler to use
140
     * @param \TechDivision\Import\Repositories\EavAttributeOptionValueRepositoryInterface $eavAttributeOptionValueRepository The EAV attribute option value repository to use
141
     * @param \TechDivision\Import\Repositories\EavAttributeRepositoryInterface            $eavAttributeRepository            The EAV attribute repository to use
142
     * @param \TechDivision\Import\Customer\Repositories\CustomerRepositoryInterface       $customerRepository                The customer repository to use
143
     * @param \TechDivision\Import\Repositories\EavEntityTypeRepositoryInterface           $eavEntityTypeRepository           The EAV entity type repository to use
144
     * @param \TechDivision\Import\Actions\ActionInterface                                 $customerAction                    The customer action to use
145
     * @param \TechDivision\Import\Actions\ActionInterface                                 $customerDatetimeAction            The customer datetime action to use
146
     * @param \TechDivision\Import\Actions\ActionInterface                                 $customerDecimalAction             The customer decimal action to use
147
     * @param \TechDivision\Import\Actions\ActionInterface                                 $customerIntAction                 The customer integer action to use
148
     * @param \TechDivision\Import\Actions\ActionInterface                                 $customerTextAction                The customer text action to use
149
     * @param \TechDivision\Import\Actions\ActionInterface                                 $customerVarcharAction             The customer varchar action to use
150
     * @param \TechDivision\Import\Loaders\LoaderInterface                                 $rawEntityLoader                   The raw entity loader instance
151
     */
152
    public function __construct(
153
        ConnectionInterface $connection,
154
        CustomerAttributeAssemblerInterface $customerAttributeAssembler,
155
        EavAttributeOptionValueRepositoryInterface $eavAttributeOptionValueRepository,
156
        EavAttributeRepositoryInterface $eavAttributeRepository,
157
        CustomerRepositoryInterface $customerRepository,
158
        EavEntityTypeRepositoryInterface $eavEntityTypeRepository,
0 ignored issues
show
Unused Code introduced by
The parameter $eavEntityTypeRepository is not used and could be removed. ( Ignorable by Annotation )

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

158
        /** @scrutinizer ignore-unused */ EavEntityTypeRepositoryInterface $eavEntityTypeRepository,

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
159
        ActionInterface $customerAction,
160
        ActionInterface $customerDatetimeAction,
161
        ActionInterface $customerDecimalAction,
162
        ActionInterface $customerIntAction,
163
        ActionInterface $customerTextAction,
164
        ActionInterface $customerVarcharAction,
165
        LoaderInterface $rawEntityLoader
166
    ) {
167
        $this->setConnection($connection);
168
        $this->setCustomerAttributeAssembler($customerAttributeAssembler);
169
        $this->setEavAttributeOptionValueRepository($eavAttributeOptionValueRepository);
170
        $this->setEavAttributeRepository($eavAttributeRepository);
171
        $this->setCustomerRepository($customerRepository);
172
        $this->setCustomerAction($customerAction);
173
        $this->setCustomerDatetimeAction($customerDatetimeAction);
174
        $this->setCustomerDecimalAction($customerDecimalAction);
175
        $this->setCustomerIntAction($customerIntAction);
176
        $this->setCustomerTextAction($customerTextAction);
177
        $this->setCustomerVarcharAction($customerVarcharAction);
178
        $this->setRawEntityLoader($rawEntityLoader);
179
    }
180
181
    /**
182
     * Set's the raw entity loader instance.
183
     *
184
     * @param \TechDivision\Import\Loaders\LoaderInterface $rawEntityLoader The raw entity loader instance to set
185
     *
186
     * @return void
187
     */
188
    public function setRawEntityLoader(LoaderInterface $rawEntityLoader)
189
    {
190
        $this->rawEntityLoader = $rawEntityLoader;
191
    }
192
193
    /**
194
     * Return's the raw entity loader instance.
195
     *
196
     * @return \TechDivision\Import\Loaders\LoaderInterface The raw entity loader instance
197
     */
198
    public function getRawEntityLoader()
199
    {
200
        return $this->rawEntityLoader;
201
    }
202
203
    /**
204
     * Set's the passed connection.
205
     *
206
     * @param \TechDivision\Import\Connection\ConnectionInterface $connection The connection to set
207
     *
208
     * @return void
209
     */
210
    public function setConnection(ConnectionInterface $connection)
211
    {
212
        $this->connection = $connection;
213
    }
214
215
    /**
216
     * Return's the connection.
217
     *
218
     * @return \TechDivision\Import\Connection\ConnectionInterface The connection instance
219
     */
220
    public function getConnection()
221
    {
222
        return $this->connection;
223
    }
224
225
    /**
226
     * Turns off autocommit mode. While autocommit mode is turned off, changes made to the database via the PDO
227
     * object instance are not committed until you end the transaction by calling CustomerProcessor::commit().
228
     * Calling CustomerProcessor::rollBack() will roll back all changes to the database and return the connection
229
     * to autocommit mode.
230
     *
231
     * @return boolean Returns TRUE on success or FALSE on failure
232
     * @link http://php.net/manual/en/pdo.begintransaction.php
233
     */
234
    public function beginTransaction()
235
    {
236
        return $this->connection->beginTransaction();
237
    }
238
239
    /**
240
     * Commits a transaction, returning the database connection to autocommit mode until the next call to
241
     * CustomerProcessor::beginTransaction() starts a new transaction.
242
     *
243
     * @return boolean Returns TRUE on success or FALSE on failure
244
     * @link http://php.net/manual/en/pdo.commit.php
245
     */
246
    public function commit()
247
    {
248
        return $this->connection->commit();
0 ignored issues
show
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...
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...
249
    }
250
251
    /**
252
     * Rolls back the current transaction, as initiated by CustomerProcessor::beginTransaction().
253
     *
254
     * If the database was set to autocommit mode, this function will restore autocommit mode after it has
255
     * rolled back the transaction.
256
     *
257
     * Some databases, including MySQL, automatically issue an implicit COMMIT when a database definition
258
     * language (DDL) statement such as DROP TABLE or CREATE TABLE is issued within a transaction. The implicit
259
     * COMMIT will prevent you from rolling back any other changes within the transaction boundary.
260
     *
261
     * @return boolean Returns TRUE on success or FALSE on failure
262
     * @link http://php.net/manual/en/pdo.rollback.php
263
     */
264
    public function rollBack()
265
    {
266
        return $this->connection->rollBack();
267
    }
268
269
    /**
270
     * Set's the repository to load the customers with.
271
     *
272
     * @param \TechDivision\Import\Customer\Repositories\CustomerRepositoryInterface $customerRepository The repository instance
273
     *
274
     * @return void
275
     */
276
    public function setCustomerRepository(CustomerRepositoryInterface $customerRepository)
277
    {
278
        $this->customerRepository = $customerRepository;
279
    }
280
281
    /**
282
     * Return's the repository to load the customers with.
283
     *
284
     * @return \TechDivision\Import\Customer\Repositories\CustomerRepositoryInterface The repository instance
285
     */
286
    public function getCustomerRepository()
287
    {
288
        return $this->customerRepository;
289
    }
290
291
    /**
292
     * Set's the action with the customer CRUD methods.
293
     *
294
     * @param \TechDivision\Import\Actions\ActionInterface $customerAction The action with the customer CRUD methods
295
     *
296
     * @return void
297
     */
298
    public function setCustomerAction(ActionInterface $customerAction)
299
    {
300
        $this->customerAction = $customerAction;
301
    }
302
303
    /**
304
     * Return's the action with the customer CRUD methods.
305
     *
306
     * @return \TechDivision\Import\Actions\ActionInterface The action instance
307
     */
308
    public function getCustomerAction()
309
    {
310
        return $this->customerAction;
311
    }
312
313
    /**
314
     * Set's the action with the customer varchar attribute CRUD methods.
315
     *
316
     * @param \TechDivision\Import\Actions\ActionInterface $customerVarcharAction The action with the customer varchar attriute CRUD methods
317
     *
318
     * @return void
319
     */
320
    public function setCustomerVarcharAction(ActionInterface $customerVarcharAction)
321
    {
322
        $this->customerVarcharAction = $customerVarcharAction;
323
    }
324
325
    /**
326
     * Return's the action with the customer varchar attribute CRUD methods.
327
     *
328
     * @return \TechDivision\Import\Actions\ActionInterface The action instance
329
     */
330
    public function getCustomerVarcharAction()
331
    {
332
        return $this->customerVarcharAction;
333
    }
334
335
    /**
336
     * Set's the action with the customer text attribute CRUD methods.
337
     *
338
     * @param \TechDivision\Import\Actions\ActionInterface $customerTextAction The action with the customer text attriute CRUD methods
339
     *
340
     * @return void
341
     */
342
    public function setCustomerTextAction(ActionInterface $customerTextAction)
343
    {
344
        $this->customerTextAction = $customerTextAction;
345
    }
346
347
    /**
348
     * Return's the action with the customer text attribute CRUD methods.
349
     *
350
     * @return \TechDivision\Import\Actions\ActionInterface The action instance
351
     */
352
    public function getCustomerTextAction()
353
    {
354
        return $this->customerTextAction;
355
    }
356
357
    /**
358
     * Set's the action with the customer int attribute CRUD methods.
359
     *
360
     * @param \TechDivision\Import\Actions\ActionInterface $customerIntAction The action with the customer int attriute CRUD methods
361
     *
362
     * @return void
363
     */
364
    public function setCustomerIntAction(ActionInterface $customerIntAction)
365
    {
366
        $this->customerIntAction = $customerIntAction;
367
    }
368
369
    /**
370
     * Return's the action with the customer int attribute CRUD methods.
371
     *
372
     * @return \TechDivision\Import\Actions\ActionInterface The action instance
373
     */
374
    public function getCustomerIntAction()
375
    {
376
        return $this->customerIntAction;
377
    }
378
379
    /**
380
     * Set's the action with the customer decimal attribute CRUD methods.
381
     *
382
     * @param \TechDivision\Import\Actions\ActionInterface $customerDecimalAction The action with the customer decimal attriute CRUD methods
383
     *
384
     * @return void
385
     */
386
    public function setCustomerDecimalAction(ActionInterface $customerDecimalAction)
387
    {
388
        $this->customerDecimalAction = $customerDecimalAction;
389
    }
390
391
    /**
392
     * Return's the action with the customer decimal attribute CRUD methods.
393
     *
394
     * @return \TechDivision\Import\Actions\ActionInterface The action instance
395
     */
396
    public function getCustomerDecimalAction()
397
    {
398
        return $this->customerDecimalAction;
399
    }
400
401
    /**
402
     * Set's the action with the customer datetime attribute CRUD methods.
403
     *
404
     * @param \TechDivision\Import\Actions\ActionInterface $customerDatetimeAction The action with the customer datetime attriute CRUD methods
405
     *
406
     * @return void
407
     */
408
    public function setCustomerDatetimeAction(ActionInterface $customerDatetimeAction)
409
    {
410
        $this->customerDatetimeAction = $customerDatetimeAction;
411
    }
412
413
    /**
414
     * Return's the action with the customer datetime attribute CRUD methods.
415
     *
416
     * @return \TechDivision\Import\Actions\ActionInterface The action instance
417
     */
418
    public function getCustomerDatetimeAction()
419
    {
420
        return $this->customerDatetimeAction;
421
    }
422
423
    /**
424
     * Set's the repository to access EAV attribute option values.
425
     *
426
     * @param \TechDivision\Import\Repositories\EavAttributeOptionValueRepositoryInterface $eavAttributeOptionValueRepository The repository to access EAV attribute option values
427
     *
428
     * @return void
429
     */
430
    public function setEavAttributeOptionValueRepository(EavAttributeOptionValueRepositoryInterface $eavAttributeOptionValueRepository)
431
    {
432
        $this->eavAttributeOptionValueRepository = $eavAttributeOptionValueRepository;
433
    }
434
435
    /**
436
     * Return's the repository to access EAV attribute option values.
437
     *
438
     * @return \TechDivision\Import\Repositories\EavAttributeOptionValueRepositoryInterface The repository instance
439
     */
440
    public function getEavAttributeOptionValueRepository()
441
    {
442
        return $this->eavAttributeOptionValueRepository;
443
    }
444
445
    /**
446
     * Set's the repository to access EAV attributes.
447
     *
448
     * @param \TechDivision\Import\Repositories\EavAttributeRepositoryInterface $eavAttributeRepository The repository to access EAV attributes
449
     *
450
     * @return void
451
     */
452
    public function setEavAttributeRepository(EavAttributeRepositoryInterface $eavAttributeRepository)
453
    {
454
        $this->eavAttributeRepository = $eavAttributeRepository;
455
    }
456
457
    /**
458
     * Return's the repository to access EAV attributes.
459
     *
460
     * @return \TechDivision\Import\Repositories\EavAttributeRepositoryInterface The repository instance
461
     */
462
    public function getEavAttributeRepository()
463
    {
464
        return $this->eavAttributeRepository;
465
    }
466
467
    /**
468
     * Set's the repository to access EAV entity types.
469
     *
470
     * @param \TechDivision\Import\Repositories\EavEntityTypeRepositoryInterface $eavEntityTypeRepository The repository to access EAV entity types
471
     *
472
     * @return void
473
     */
474
    public function setEavEntityTypeRepository(EavEntityTypeRepositoryInterface $eavEntityTypeRepository)
475
    {
476
        $this->eavEntityTypeRepository = $eavEntityTypeRepository;
477
    }
478
479
    /**
480
     * Return's the repository to access EAV entity types.
481
     *
482
     * @return \TechDivision\Import\Repositories\EavEntityTypeRepositoryInterface The repository instance
483
     */
484
    public function getEavEntityTypeRepository()
485
    {
486
        return $this->eavAttributeRepository;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->eavAttributeRepository returns the type TechDivision\Import\Repo...buteRepositoryInterface which is incompatible with the documented return type TechDivision\Import\Repo...TypeRepositoryInterface.
Loading history...
487
    }
488
489
    /**
490
     * Set's the assembler to load the customer attributes with.
491
     *
492
     * @param \TechDivision\Import\Customer\Assemblers\CustomerAttributeAssemblerInterface $customerAttributeAssembler The assembler instance
493
     *
494
     * @return void
495
     */
496
    public function setCustomerAttributeAssembler(CustomerAttributeAssemblerInterface $customerAttributeAssembler)
497
    {
498
        $this->customerAttributeAssembler = $customerAttributeAssembler;
499
    }
500
501
    /**
502
     * Return's the assembler to load the customer attributes with.
503
     *
504
     * @return \TechDivision\Import\Customer\Assemblers\CustomerAttributeAssemblerInterface The assembler instance
505
     */
506
    public function getCustomerAttributeAssembler()
507
    {
508
        return $this->customerAttributeAssembler;
509
    }
510
511
    /**
512
     * Return's an array with the available EAV attributes for the passed is user defined flag.
513
     *
514
     * @param integer $isUserDefined The flag itself
515
     *
516
     * @return array The array with the EAV attributes matching the passed flag
517
     */
518
    public function getEavAttributeByIsUserDefined($isUserDefined = 1)
519
    {
520
        return $this->getEavAttributeRepository()->findAllByIsUserDefined($isUserDefined);
521
    }
522
523
    /**
524
     * Intializes the existing attributes for the entity with the passed entity ID.
525
     *
526
     * @param integer $entityId The entity ID of the entity to load the attributes for
527
     *
528
     * @return array The entity attributes
529
     */
530
    public function getCustomerAttributesByEntityId($entityId)
531
    {
532
        return $this->getCustomerAttributeAssembler()->getCustomerAttributesByEntityId($entityId);
533
    }
534
535
    /**
536
     * Load's and return's a raw entity without primary key but the mandatory members only and nulled values.
537
     *
538
     * @param string $entityTypeCode The entity type code to return the raw entity for
539
     * @param array  $data           An array with data that will be used to initialize the raw entity with
540
     *
541
     * @return array The initialized entity
542
     */
543
    public function loadRawEntity($entityTypeCode, array $data = array())
544
    {
545
        return $this->getRawEntityLoader()->load($entityTypeCode, $data);
0 ignored issues
show
Unused Code introduced by
The call to TechDivision\Import\Load...LoaderInterface::load() has too many arguments starting with $entityTypeCode. ( Ignorable by Annotation )

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

545
        return $this->getRawEntityLoader()->/** @scrutinizer ignore-call */ load($entityTypeCode, $data);

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...
Bug Best Practice introduced by
The expression return $this->getRawEnti...$entityTypeCode, $data) returns the type ArrayAccess which is incompatible with the documented return type array.
Loading history...
546
    }
547
548
    /**
549
     * Load's and return's the EAV attribute option value with the passed entity type ID, code, store ID and value.
550
     *
551
     * @param string  $entityTypeId  The entity type ID of the EAV attribute to load the option value for
552
     * @param string  $attributeCode The code of the EAV attribute option to load
553
     * @param integer $storeId       The store ID of the attribute option to load
554
     * @param string  $value         The value of the attribute option to load
555
     *
556
     * @return array The EAV attribute option value
557
     */
558
    public function loadAttributeOptionValueByEntityTypeIdAndAttributeCodeAndStoreIdAndValue($entityTypeId, $attributeCode, $storeId, $value)
559
    {
560
        return $this->getEavAttributeOptionValueRepository()->findOneByEntityTypeIdAndAttributeCodeAndStoreIdAndValue($entityTypeId, $attributeCode, $storeId, $value);
561
    }
562
563
    /**
564
     * Return's an EAV entity type with the passed entity type code.
565
     *
566
     * @param string $entityTypeCode The code of the entity type to return
567
     *
568
     * @return array The entity type with the passed entity type code
569
     */
570
    public function loadEavEntityTypeByEntityTypeCode($entityTypeCode)
571
    {
572
        return $this->getEavEntityTypeRepository()->findOneByEntityTypeCode($entityTypeCode);
573
    }
574
575
    /**
576
     * Return's the customer with the passed email and website ID.
577
     *
578
     * @param string $email     The email of the customer to return
579
     * @param string $websiteId The website ID of the customer to return
580
     *
581
     * @return array|null The customer
582
     */
583
    public function loadCustomerByEmailAndWebsiteId($email, $websiteId)
584
    {
585
        return $this->getCustomerRepository()->findOneByEmailAndWebsiteId($email, $websiteId);
586
    }
587
588
    /**
589
     * Persist's the passed customer data and return's the ID.
590
     *
591
     * @param array       $customer The customer data to persist
592
     * @param string|null $name     The name of the prepared statement that has to be executed
593
     *
594
     * @return string The ID of the persisted entity
595
     */
596
    public function persistCustomer($customer, $name = null)
597
    {
598
        return $this->getCustomerAction()->persist($customer, $name);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getCustome...rsist($customer, $name) returns the type void which is incompatible with the documented return type string.
Loading history...
Bug introduced by
Are you sure the usage of $this->getCustomerAction...rsist($customer, $name) 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...
599
    }
600
601
    /**
602
     * Persist's the passed customer varchar attribute.
603
     *
604
     * @param array       $attribute The attribute to persist
605
     * @param string|null $name      The name of the prepared statement that has to be executed
606
     *
607
     * @return void
608
     */
609
    public function persistCustomerVarcharAttribute($attribute, $name = null)
610
    {
611
        $this->getCustomerVarcharAction()->persist($attribute, $name);
612
    }
613
614
    /**
615
     * Persist's the passed customer integer attribute.
616
     *
617
     * @param array       $attribute The attribute to persist
618
     * @param string|null $name      The name of the prepared statement that has to be executed
619
     *
620
     * @return void
621
     */
622
    public function persistCustomerIntAttribute($attribute, $name = null)
623
    {
624
        $this->getCustomerIntAction()->persist($attribute, $name);
625
    }
626
627
    /**
628
     * Persist's the passed customer decimal attribute.
629
     *
630
     * @param array       $attribute The attribute to persist
631
     * @param string|null $name      The name of the prepared statement that has to be executed
632
     *
633
     * @return void
634
     */
635
    public function persistCustomerDecimalAttribute($attribute, $name = null)
636
    {
637
        $this->getCustomerDecimalAction()->persist($attribute, $name);
638
    }
639
640
    /**
641
     * Persist's the passed customer datetime attribute.
642
     *
643
     * @param array       $attribute The attribute to persist
644
     * @param string|null $name      The name of the prepared statement that has to be executed
645
     *
646
     * @return void
647
     */
648
    public function persistCustomerDatetimeAttribute($attribute, $name = null)
649
    {
650
        $this->getCustomerDatetimeAction()->persist($attribute, $name);
651
    }
652
653
    /**
654
     * Persist's the passed customer text attribute.
655
     *
656
     * @param array       $attribute The attribute to persist
657
     * @param string|null $name      The name of the prepared statement that has to be executed
658
     *
659
     * @return void
660
     */
661
    public function persistCustomerTextAttribute($attribute, $name = null)
662
    {
663
        $this->getCustomerTextAction()->persist($attribute, $name);
664
    }
665
666
    /**
667
     * Delete's the entity with the passed attributes.
668
     *
669
     * @param array       $row  The attributes of the entity to delete
670
     * @param string|null $name The name of the prepared statement that has to be executed
671
     *
672
     * @return void
673
     */
674
    public function deleteCustomer($row, $name = null)
675
    {
676
        $this->getCustomerAction()->delete($row, $name);
677
    }
678
679
    /**
680
     * Delete's the customer datetime attribute with the passed attributes.
681
     *
682
     * @param array       $row  The attributes of the entity to delete
683
     * @param string|null $name The name of the prepared statement that has to be executed
684
     *
685
     * @return void
686
     */
687
    public function deleteCustomerDatetimeAttribute($row, $name = null)
688
    {
689
        $this->getCustomerDatetimeAction()->delete($row, $name);
690
    }
691
692
    /**
693
     * Delete's the customer decimal attribute with the passed attributes.
694
     *
695
     * @param array       $row  The attributes of the entity to delete
696
     * @param string|null $name The name of the prepared statement that has to be executed
697
     *
698
     * @return void
699
     */
700
    public function deleteCustomerDecimalAttribute($row, $name = null)
701
    {
702
        $this->getCustomerDecimalAction()->delete($row, $name);
703
    }
704
705
    /**
706
     * Delete's the customer integer attribute with the passed attributes.
707
     *
708
     * @param array       $row  The attributes of the entity to delete
709
     * @param string|null $name The name of the prepared statement that has to be executed
710
     *
711
     * @return void
712
     */
713
    public function deleteCustomerIntAttribute($row, $name = null)
714
    {
715
        $this->getCustomerIntAction()->delete($row, $name);
716
    }
717
718
    /**
719
     * Delete's the customer text attribute with the passed attributes.
720
     *
721
     * @param array       $row  The attributes of the entity to delete
722
     * @param string|null $name The name of the prepared statement that has to be executed
723
     *
724
     * @return void
725
     */
726
    public function deleteCustomerTextAttribute($row, $name = null)
727
    {
728
        $this->getCustomerTextAction()->delete($row, $name);
729
    }
730
731
    /**
732
     * Delete's the customer varchar attribute with the passed attributes.
733
     *
734
     * @param array       $row  The attributes of the entity to delete
735
     * @param string|null $name The name of the prepared statement that has to be executed
736
     *
737
     * @return void
738
     */
739
    public function deleteCustomerVarcharAttribute($row, $name = null)
740
    {
741
        $this->getCustomerVarcharAction()->delete($row, $name);
742
    }
743
744
    /**
745
     * Clean-Up the repositories to free memory.
746
     *
747
     * @return void
748
     */
749
    public function cleanUp()
750
    {
751
        // flush the cache
752
    }
753
}
754