<commit_before><?php

namespace ATPViz\DataSource;

class SOAP extends AbstractDataSource
{
	public function getData()
	{
		$options = $this->getOptions();
		$url = $options['url'];
		$namespace = $options['namespace'];
		$client = new \ATP\Soap\Client($url, $namespace);

		$headers = array();
		foreach($options['headers'] as $name => $params)
		{
			$header = new \ATP\Soap\Header($namespace, $name);
			foreach($params as $name => $value)
			{
				$header->$name = $value;
			}
			$headers[] = $header;
		}
		$client->__setHeaders($headers);
		
		$function = $options['function'];
		$node = $client->$function();
		
		if(isset($options['dataElement']))
		{
			$nodes = explode("\\", $options['dataElement']);
			foreach($nodes as $curNode)
			{
				$node = $node[$curNode];
			}
		}
		
		if($options['extractAttributes'])
		{
			foreach($node as &$item)
			{
				if(isset($item['@attributes']))
				{
					$item = array_merge($item, $item['@attributes']);
					unset($item['@attributes']);
				}
			}
		}
		
		$columns = count($node) > 0 ? array_keys($node[0]) : array();
		
		return array(<commit_msg>Simplify soap data element access<commit_after><?php

namespace ATPViz\DataSource;

class SOAP extends AbstractDataSource
{
	public function getData()
	{
		$options = $this->getOptions();
		$url = $options['url'];
		$namespace = $options['namespace'];
		$client = new \ATP\Soap\Client($url, $namespace);

		$headers = array();
		foreach($options['headers'] as $name => $params)
		{
			$header = new \ATP\Soap\Header($namespace, $name);
			foreach($params as $name => $value)
			{
				$header->$name = $value;
			}
			$headers[] = $header;
		}
		$client->__setHeaders($headers);
		
		$function = $options['function'];
		$node = $client->$function();
		
		$node = $node["{$function}Response"]["{$function}Result"];
		if(isset($options['dataElement']))
		{
			$nodes = explode("\\", $options['dataElement']);
			foreach($nodes as $curNode)
			{
				$node = $node[$curNode];
			}
		}
		
		if($options['extractAttributes'])
		{
			foreach($node as &$item)
			{
				if(isset($item['@attributes']))
				{
					$item = array_merge($item, $item['@attributes']);
					unset($item['@attributes']);
				}
			}
		}
		
		$columns = count($node) > 0 ? array_keys($node[0]) : array();
		
		return array(
{'fraction_non_alphanumeric': 0.20584387265590928, 'fraction_numerical': 0.0017444395987788923, 'mean_word_length': 3.7008196721311477, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6694709', 'n_tokens_mistral': 932, 'n_tokens_neox': 757, 'n_words': 141}