eduCode = trim($eduCode); $this->eduName = trim($eduName); $this->eduLevel = trim($eduLevel); $this->eduForm = trim($eduForm); $this->avgScore = (float)str_replace(',', '.', $avgScore); $this->calcContingent($contingent); } public function getData(): array { return [ 'spec_code' => $this->eduCode, 'spec_name' => $this->eduName, 'edu_level' => $this->eduLevel, 'edu_forms'=> $this->eduForm, 'avgScore' => $this->avgScore, 'contongent' => $this->all, 'budget' => $this->budget, ]; } private function calcContingent(array $contingent): void { $all = 0; $budget = 0; foreach ($contingent as $key => $con) { $all += (int)$con; if ($key !== 3) { $budget += $con; } } $this->all = $all; $this->budget = $budget; } }