Example #1
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.");
 }
Example #2
0
 /**
  *
  */
 public function testIsAssoc()
 {
     $this->assertTrue(Arr::isAssoc(['foo' => 0, 'bar' => 1]));
     $this->assertFalse(Arr::isAssoc([0 => 'foo', 1 => 'bar']));
     $this->assertFalse(Arr::isAssoc(['foo' => 0, 1 => 'bar']));
 }