Completed
Pull Request — master (#17)
by
unknown
01:17
created

BodyFactory::createBodyContent()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 9.536
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php declare(strict_types=1);
2
3
namespace h4kuna\Ares;
4
5
class BodyFactory
6
{
7
8
9
	/**
10
	 * @param array|string[] $identificationNumbers
11
	 * @return string
12
	 * @throws \Exception
13
	 */
14
	public function createBodyContent(array $identificationNumbers): string
15
	{
16
		$date = new \DateTime();
17
		$content = '
18
		<are:Ares_dotazy 
19
		xmlns:are="http://wwwinfo.mfcr.cz/ares/xml_doc/schemas/ares/ares_request_orrg/v_1.0.0" 
20
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
21
		xsi:schemaLocation="http://wwwinfo.mfcr.cz/ares/xml_doc/schemas/ares/ares_request_orrg/v_1.0.0 http://wwwinfo.mfcr.cz/ares/xml_doc/schemas/ares/ares_request_orrg/v_1.0.0/ares_request_orrg.xsd" 
22
		dotaz_datum_cas="' . $date->format('Y-m-dTH:i:s') . '" 
23
		dotaz_pocet="' . count($identificationNumbers) . '" 
24
		dotaz_typ="Basic" 
25
		vystup_format="XML" 
26
		validation_XSLT="http://wwwinfo.mfcr.cz/ares/xml_doc/schemas/ares/ares_answer/v_1.0.0/ares_answer.xsl" 
27
		answerNamespaceRequired="http://wwwinfo.mfcr.cz/ares/xml_doc/schemas/ares/ares_answer_basic/v_1.0.3"
28
		Id="Ares_dotaz">
29
		';
30
31
		foreach ($identificationNumbers as $key => $in) {
32
			$content .=  '<Dotaz><Pomocne_ID>' . $key . '</Pomocne_ID><ICO>' . $in . '</ICO></Dotaz>';
33
		}
34
35
		$content .= '</are:Ares_dotazy>';
36
		return $content;
37
	}
38
39
}
40