Ejemplo n.º 1
0
 /**
  * Nice magic access to stored path's.
  *
  * @param string $method The method name
  * @param $arguments $arguments One argument to pass by would be a new path to be set
  *
  * @author Benjamin Carl <*****@*****.**>
  *
  * @return mixed Result depending on operation
  *
  * @throws Doozr_Path_Exception
  */
 public function __call($method, $arguments)
 {
     $method = str_split_camelcase($method);
     if (count($method) === 2) {
         $identifier = strtolower($method[1]);
         if (isset(self::$path[$identifier]) === false) {
             throw new Doozr_Path_Exception(sprintf('Path "%s" does not exist!', $identifier));
         } else {
             if (strtolower($method[0]) === 'get') {
                 $result = self::$path[$identifier];
             } else {
                 $result = self::$path[$identifier] = isset($arguments[0]) ? $arguments[0] : null;
             }
             return $result;
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Magic wrapper acts as generic setter and getter.
  *
  * @param string $method   The method called (e.g. setFoo('bar') or getFoo()
  * @param array  $argument The argument for setter (e.g. 'bar')
  *
  * @author Benjamin Carl <*****@*****.**>
  *
  * @return mixed Result of operation
  */
 public function __call($method, $argument = [])
 {
     $method = str_split_camelcase($method);
     switch (strtolower($method[0])) {
         case 'get':
             return $this->configuration->{strtolower($method[1])};
             break;
         case 'set':
             return $this->configuration->{strtolower($method[1])} = $argument[0];
             break;
         default:
             return;
             break;
     }
 }
Ejemplo n.º 3
0
 /**
  * Magic implementation to prevent us spamming the class body with thousands of getters and setters for all those
  * special attributes that exist. Like id, name, style, and so on. This basic implementation transforms calls like.
  *
  * @example
  *  - getName() <=> getAttribute('name');
  *  - setName('foo') <=> setAttribute('name', 'foo');
  *  - ...
  *
  * @param string $method    Method called (e.g. setId())
  * @param array  $arguments Arguments passed while calling $method
  *
  * @return null|void
  *
  * @throws Doozr_Form_Service_Exception
  */
 public function __call($method, $arguments)
 {
     // assume we can't call anything!
     $result = null;
     // try to split the method
     $methodSplitted = str_split_camelcase($method);
     // check requirements
     if ($methodSplitted[0] !== 'set' && $methodSplitted[0] !== 'get' || !isset($methodSplitted[1])) {
         trigger_error(sprintf('Call to undefined function: "%s" with arguments: "%s"', $method, var_export($arguments, true) . PHP_EOL));
     }
     // extract the property from call
     $property = strtolower($methodSplitted[1]);
     // dispatch to correct method
     if ($methodSplitted[0] === 'get') {
         return $this->getAttribute($property);
     } else {
         if (count($arguments) === 0) {
             $arguments[0] = null;
         }
         $this->setAttribute($property, $this->value($arguments[0]));
     }
     // for chaining calls
     return $this;
 }
Ejemplo n.º 4
0
 /**
  * Get The name of the class, with namespacing and underscores stripped.
  *
  * @param  string  $class
  *
  * @return string
  */
 public static function className($class = '')
 {
     $name = self::getShortNameClass($class);
     $name = str_split_camelcase($name, '_');
     return strtolower(urlencode($name));
 }