@@ -75,10 +75,8 @@ class DataObjectHandler implements ObjectHandlerInterface
75
75
76
76
/**
77
77
* Constructor
78
- * @param boolean $validateName Set to false to disable name validations.
79
- * @throws XmlException
80
78
*/
81
- private function __construct ($ validateName = true )
79
+ private function __construct ()
82
80
{
83
81
$ parser = ObjectManagerFactory::getObjectManager ()->create (DataProfileSchemaParser::class);
84
82
$ parserOutput = $ parser ->readDataProfiles ();
@@ -87,21 +85,20 @@ private function __construct($validateName = true)
87
85
}
88
86
$ this ->entityNameValidator = new NameValidationUtil ();
89
87
$ this ->entityKeyValidator = new NameValidationUtil ();
90
- $ this ->entityDataObjects = $ this ->processParserOutput ($ parserOutput, $ validateName );
88
+ $ this ->entityDataObjects = $ this ->processParserOutput ($ parserOutput );
91
89
$ this ->extendUtil = new DataExtensionUtil ();
92
90
}
93
91
94
92
/**
95
93
* Return the singleton instance of this class. Initialize it if needed.
96
94
*
97
- * @param boolean $validateName
98
95
* @return DataObjectHandler
99
96
* @throws \Exception
100
97
*/
101
- public static function getInstance ($ validateName = true )
98
+ public static function getInstance ()
102
99
{
103
100
if (!self ::$ INSTANCE ) {
104
- self ::$ INSTANCE = new DataObjectHandler ($ validateName );
101
+ self ::$ INSTANCE = new DataObjectHandler ();
105
102
}
106
103
return self ::$ INSTANCE ;
107
104
}
@@ -138,13 +135,11 @@ public function getAllObjects()
138
135
* Convert the parser output into a collection of EntityDataObjects
139
136
*
140
137
* @param string[] $parserOutput Primitive array output from the Magento parser.
141
- * @param boolean $validateName
142
138
* @return EntityDataObject[]
143
139
* @throws XmlException
144
140
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
145
- * @SuppressWarnings(PHPMD.NPathComplexity)
146
141
*/
147
- private function processParserOutput ($ parserOutput, $ validateName = true )
142
+ private function processParserOutput ($ parserOutput )
148
143
{
149
144
$ entityDataObjects = [];
150
145
$ rawEntities = $ parserOutput [self ::_ENTITY ];
@@ -155,13 +150,11 @@ private function processParserOutput($parserOutput, $validateName = true)
155
150
}
156
151
157
152
$ filename = $ rawEntity [self ::_FILENAME ] ?? null ;
158
- if ($ validateName ) {
159
- $ this ->entityNameValidator ->validatePascalCase (
160
- $ name ,
161
- NameValidationUtil::DATA_ENTITY_NAME ,
162
- $ filename
163
- );
164
- }
153
+ $ this ->entityNameValidator ->validatePascalCase (
154
+ $ name ,
155
+ NameValidationUtil::DATA_ENTITY_NAME ,
156
+ $ filename
157
+ );
165
158
$ type = $ rawEntity [self ::_TYPE ] ?? null ;
166
159
$ data = [];
167
160
$ deprecated = null ;
@@ -171,7 +164,7 @@ private function processParserOutput($parserOutput, $validateName = true)
171
164
$ parentEntity = null ;
172
165
173
166
if (array_key_exists (self ::_DATA , $ rawEntity )) {
174
- $ data = $ this ->processDataElements ($ rawEntity, $ validateName );
167
+ $ data = $ this ->processDataElements ($ rawEntity );
175
168
$ uniquenessData = $ this ->processUniquenessData ($ rawEntity );
176
169
}
177
170
@@ -217,10 +210,8 @@ private function processParserOutput($parserOutput, $validateName = true)
217
210
218
211
$ entityDataObjects [$ entityDataObject ->getName ()] = $ entityDataObject ;
219
212
}
220
- if ($ validateName ) {
221
- $ this ->entityNameValidator ->summarize (NameValidationUtil::DATA_ENTITY_NAME );
222
- $ this ->entityKeyValidator ->summarize (NameValidationUtil::DATA_ENTITY_KEY );
223
- }
213
+ $ this ->entityNameValidator ->summarize (NameValidationUtil::DATA_ENTITY_NAME );
214
+ $ this ->entityKeyValidator ->summarize (NameValidationUtil::DATA_ENTITY_KEY );
224
215
return $ entityDataObjects ;
225
216
}
226
217
@@ -246,22 +237,19 @@ private function processArray($arrayItems, $data, $key)
246
237
* Parses <data> elements in an entity, and returns them as an array of "lowerKey"=>value.
247
238
*
248
239
* @param string[] $entityData
249
- * @param boolean $validateName
250
240
* @return string[]
251
241
*/
252
- private function processDataElements ($ entityData, $ validateName = true )
242
+ private function processDataElements ($ entityData )
253
243
{
254
244
$ dataValues = [];
255
245
foreach ($ entityData [self ::_DATA ] as $ dataElement ) {
256
246
$ originalDataElementKey = $ dataElement [self ::_KEY ];
257
247
$ filename = $ entityData [self ::_FILENAME ] ?? null ;
258
- if ($ validateName ) {
259
- $ this ->entityKeyValidator ->validateCamelCase (
260
- $ originalDataElementKey ,
261
- NameValidationUtil::DATA_ENTITY_KEY ,
262
- $ filename
263
- );
264
- }
248
+ $ this ->entityKeyValidator ->validateCamelCase (
249
+ $ originalDataElementKey ,
250
+ NameValidationUtil::DATA_ENTITY_KEY ,
251
+ $ filename
252
+ );
265
253
$ dataElementKey = strtolower ($ originalDataElementKey );
266
254
$ dataElementValue = $ dataElement [self ::_VALUE ] ?? "" ;
267
255
$ dataValues [$ dataElementKey ] = $ dataElementValue ;
0 commit comments