-
Notifications
You must be signed in to change notification settings - Fork 132
/
Copy pathArgumentParser.php
49 lines (45 loc) · 1.37 KB
/
ArgumentParser.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\FunctionalTestingFramework\ObjectManager\Config\Mapper;
use Magento\FunctionalTestingFramework\Config\Converter\Dom\Flat as FlatConverter;
use Magento\FunctionalTestingFramework\Config\Dom\ArrayNodeConfig;
use Magento\FunctionalTestingFramework\Config\Dom\NodePathMatcher;
/**
* Parser of a DI argument node that returns its array representation with no data loss
*/
class ArgumentParser
{
/**
* Converter.
*
* @var FlatConverter
*/
private $converter;
/**
* Build and return array representation of DI argument node
*
* @param \DOMNode $argumentNode
* @return array|string
*/
public function parse(\DOMNode $argumentNode)
{
// Base path is specified to use more meaningful XPaths in config
return $this->getConverter()->convert($argumentNode, 'argument');
}
/**
* Retrieve instance of XML converter, suitable for DI argument nodes
*
* @return FlatConverter
*/
protected function getConverter()
{
if (!$this->converter) {
$arrayNodeConfig = new ArrayNodeConfig(new NodePathMatcher(), ['argument(/item)+' => 'name']);
$this->converter = new FlatConverter($arrayNodeConfig);
}
return $this->converter;
}
}