Esempio n. 1
0
 /**
  * Convert array selector representation (['baz', 'foo_bar']) to
  * English friendly representation (Bar Foo Bar).
  *
  * If selector name is ends with "_id", then Id is dropped off the name.
  * 
  * @param Gajus\Vlad\Selector $selector
  * @return string
  */
 public static function deriveSelectorName(\Gajus\Vlad\Selector $selector)
 {
     $path = explode('_', implode('_', array_filter($selector->getpath())));
     if (count($path) > 1 && $path[count($path) - 1] == 'id') {
         array_pop($path);
     }
     return ucwords(implode(' ', $path));
 }
Esempio n. 2
0
File: Input.php Progetto: gajus/vlad
 /**
  * @param Gajus\Vlad\Selector $selector
  * @return mixed
  */
 public function getValue(\Gajus\Vlad\Selector $selector)
 {
     $value = $this->input;
     foreach ($selector->getPath() as $crumb) {
         if (array_key_exists($crumb, $value)) {
             $value = $value[$crumb];
         } else {
             $value = null;
             break;
         }
     }
     return $value;
 }