/** * @return bool * @throws \Exception */ public function send() { // Simple cleanup $this->_headers = Arr::clean($this->_headers); $this->_atachments = Arr::clean($this->_atachments); if ($this->_validateMode !== self::VALIDATE_NO_CHECK) { if (!$this->_subject) { $this->_error('Subject is empty'); } if (!$this->_body) { $this->_error('Body is empty'); } if (count($this->_recipient) !== 2) { $this->_error('Recipient is empty'); } } $result = false; try { if ($result = $this->_send()) { $this->clean(); } } catch (\Exception $e) { $this->_error($e->getMessage()); } return $result; }
public function testClean() { $input = array('a', 'b', '', null, false, 0); $expect = array('a', 'b'); isSame($expect, Arr::clean($input)); }
/** * Cleanup array * * @param mixed $value * @param string|\Closure $filter * @return string */ public static function arr($value, $filter = null) { $array = (array) $value; if ($filter === 'noempty') { $array = Arr::clean($array); } elseif ($filter instanceof \Closure) { $array = array_filter($array, $filter); // TODO add support both - key + value } return $array; }