/** * Retrieves the files * * @param Employee $employee * @param string $paths * @param string $month * @return void * @author Francisco Iglesias Gómez */ public function retrieveFiles(Employee $employee, $paths, $month) { $pattern = sprintf('/_trabajador_(%s)_/', implode('|', $employee->getPayrolls())); $finder = $this->getAllPayrollFiles($paths, $month)->name($pattern); if (!iterator_count($finder)) { throw new EmployeeHasNoPayrollFiles(sprintf('Employee %s has no payroll files for month %s', $employee->getFullName(), $month)); } return $finder; }
public function testItCanBeCreatedFromYamlArray() { $data = array('email' => '*****@*****.**', 'firstname' => 'Fran', 'lastname' => 'Iglesias', 'gender' => 'male', 'payrolls' => array(123456)); $employee = Employee::fromArray($data); $expected = new Employee('*****@*****.**', 'Fran', 'Iglesias', 'male', array(123456)); $this->assertEquals($expected, $employee); }
/** * Builds and send the email message to the employee * * @param string $employee * @param string $sender * @param string $month * @return boolean true on success * @author Fran Iglesias */ private function sendEmail(Employee $employee, $sender, $paths, PayrollMonth $month) { $message = new MailMessage(); $message->setTo($employee->getEmail())->setSender($sender)->setTemplate($this->template, array('employee' => $employee, 'month' => $month))->attach($this->getPayrollDocuments($employee, $paths, $month)); return $this->mailer->send($message); }