Example #1
0
 /**
  *
  */
 public function testHas()
 {
     $arr = ['foo' => '123', 'bar' => ['baz' => '456', 'bax' => ['789']]];
     $this->assertTrue(Arr::has($arr, 'foo'));
     $this->assertTrue(Arr::has($arr, 'bar.baz'));
     $this->assertTrue(Arr::has($arr, 'bar.bax.0'));
     $this->assertFalse(Arr::has($arr, 'bar.bax.1'));
 }
Example #2
0
 /**
  * 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);
 }
Example #3
0
 /**
  * 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);
 }
Example #4
0
 /**
  * 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.");
 }