header = $header; $this->details = $details; $this->movements = $movements; } public function getHeader(): array { return $this->header; } public function getDetails(): array { return $this->details; } public function getMovements(): array { return $this->movements; } public function extractPeriod(): array { if (array_key_exists('НачПериода', $this->header)) { $startDate = \DateTime::createFromFormat('d.m.Y', $this->header['НачПериода']); $endDate = \DateTime::createFromFormat('d.m.Y', $this->header['КонПериода']); } elseif (array_key_exists('СтрокаПериода', $this->header)) { $chunks = explode(' ', $this->header['СтрокаПериода']); if(count($chunks) !== 4) throw new \Exception('Unexpected period format!'); $startDate = \DateTime::createFromFormat('d.m.Y', $chunks[1]); $endDate = \DateTime::createFromFormat('d.m.Y', $chunks[3]); } else { throw new \Exception('Can not detect xml header version!'); } return [$startDate, $endDate]; } }