|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* TechDivision\Import\Configuration\Jms\Configuration\Subject\ImportAdapter |
|
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 2016 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-configuration-jms |
|
18
|
|
|
* @link http://www.techdivision.com |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Configuration\Jms\Configuration\Subject; |
|
22
|
|
|
|
|
23
|
|
|
use JMS\Serializer\Annotation\Type; |
|
24
|
|
|
use JMS\Serializer\Annotation\SerializedName; |
|
25
|
|
|
use JMS\Serializer\Annotation\PostDeserialize; |
|
26
|
|
|
use TechDivision\Import\Utils\DependencyInjectionKeys; |
|
27
|
|
|
use TechDivision\Import\Configuration\Jms\Configuration\CsvTrait; |
|
28
|
|
|
use TechDivision\Import\Configuration\Subject\ImportAdapterConfigurationInterface; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* The import adapter's configuration. |
|
32
|
|
|
* |
|
33
|
|
|
* @author Tim Wagner <[email protected]> |
|
34
|
|
|
* @copyright 2016 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-configuration-jms |
|
37
|
|
|
* @link http://www.techdivision.com |
|
38
|
|
|
*/ |
|
39
|
|
View Code Duplication |
class ImportAdapter implements ImportAdapterConfigurationInterface |
|
|
|
|
|
|
40
|
|
|
{ |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Trait that provides CSV configuration functionality. |
|
44
|
|
|
* |
|
45
|
|
|
* @var \TechDivision\Import\Configuration\Jms\CsvTrait |
|
46
|
|
|
*/ |
|
47
|
|
|
use CsvTrait; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* The import adapter's unique DI identifier. |
|
51
|
|
|
* |
|
52
|
|
|
* @var string |
|
53
|
|
|
* @Type("string") |
|
54
|
|
|
*/ |
|
55
|
|
|
protected $id = DependencyInjectionKeys::IMPORT_ADAPTER_IMPORT_CSV_FACTORY; |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* The filesystem adapter configuration instance. |
|
59
|
|
|
* |
|
60
|
|
|
* @var \TechDivision\Import\Configuration\Subject\SerializerConfigurationInterface |
|
61
|
|
|
* @Type("TechDivision\Import\Configuration\Jms\Configuration\Subject\Serializer") |
|
62
|
|
|
* @SerializedName("serializer") |
|
63
|
|
|
*/ |
|
64
|
|
|
protected $serializer; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Return's the import adapter's unique DI identifier |
|
68
|
|
|
* |
|
69
|
|
|
* @return string The import adapter's unique DI identifier |
|
70
|
|
|
*/ |
|
71
|
|
|
public function getId() |
|
72
|
|
|
{ |
|
73
|
|
|
return $this->id; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Return's the serializer configuration instance. |
|
78
|
|
|
* |
|
79
|
|
|
* @return \TechDivision\Import\Configuration\Subject\SerializerConfigurationInterface The serializer configuration instance |
|
80
|
|
|
*/ |
|
81
|
|
|
public function getSerializer() |
|
82
|
|
|
{ |
|
83
|
|
|
return $this->serializer; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Lifecycle callback that will be invoked after deserialization. |
|
88
|
|
|
* |
|
89
|
|
|
* @return void |
|
90
|
|
|
* @PostDeserialize |
|
91
|
|
|
*/ |
|
92
|
|
|
public function postDeserialize() |
|
93
|
|
|
{ |
|
94
|
|
|
|
|
95
|
|
|
// set a default serializer if none has been configured |
|
96
|
|
|
if ($this->serializer === null) { |
|
97
|
|
|
$this->serializer = new Serializer(); |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.