/** * */ public function testPluck() { $arr = [['foo' => 'bar'], ['foo' => 'baz']]; $this->assertEquals(['bar', 'baz'], Arr::pluck($arr, 'foo')); // $obj1 = new \StdClass(); $obj1->foo = 'bar'; $obj2 = new \StdClass(); $obj2->foo = 'baz'; $arr = [$obj1, $obj2]; $this->assertEquals(['bar', 'baz'], Arr::pluck($arr, 'foo')); }
/** * Set email blind carbon copy addresses / names * * @access public * @param string $email A unique or array of valid emails addresses * @param string $name (optional) Set a receiver name * @return \carteiro\Mail */ public function bcc($email, $name = null) { if (is_array($email)) { foreach ($email as $address) { // Fix array if (!is_array($address)) { $address = array($address); } // Set convention $this->bcc[] = ['email' => Arr::get($address, 0), 'name' => Arr::get($address, 1)]; } } else { // Set normal $this->bcc[] = ['email' => $email, 'name' => $name]; } return $this; }
/** * Returns an array containing only the values of chosen column. * * @access public * @param string $column Column name * @return array */ public function pluck($column) { return Arr::pluck($this->items, $column); }
/** * Returns TRUE if the string exists and FALSE if not. * * @access public * @param string $key String to translate * @param string $language Name of the language pack * @return boolean */ public function has($key, $language = null) { $language = $language ?? $this->language; list($file, $string) = $this->parseKey($key); if (!isset($this->strings[$language][$file])) { $this->loadStrings($language, $file); } return Arr::has($this->strings[$language][$file], $string); }
/** * Checks if the keys exist in the data of the current request method. * * @access public * @param string $key Array key * @return boolean */ public function has($key) { $method = strtolower($this->realMethod); return Arr::has($this->{$method}(), $key); }
/** * Extract parsed views by string or array. * * @access protected * @param mixed $views View parameters * @return array * * @throws \InvalidArgumentException */ protected function extractViews($views) { // Return only html view if (is_string($views)) { return [$views, null, null]; } // If the given view is an array with numeric or associative keys if (is_array($views)) { if (Arr::isAssoc($views)) { // Return only raw body content if (Arr::has($views, 'raw') && Arr::get($views, 'raw')) { return [null, null, Arr::get($views, 'raw')]; } else { // Return associative values in order (html | text | raw) return [Arr::get($views, 'html'), Arr::get($views, 'text'), null]; } } else { // Return numeric values in order (html | text | raw) return [Arr::get($views, 0), Arr::get($views, 1), null]; } } throw new \InvalidArgumentException("Invalid view parameters."); }
/** * Removes a value from the configuration. * * @access public * @param string $key Config key * @return boolean */ public function remove($key) { return Arr::delete($this->configuration, $key); }