Esempio n. 1
0
 /**
  * @author WN
  * @param string $name
  * @param array $arguments
  * @return $this
  */
 public function __call($name, $arguments)
 {
     $action = substr($name, 0, 3);
     $property = NameHelper::camelToSnake(substr($name, 3));
     if ($this->isPropertyAllowed($property)) {
         switch ($action) {
             case 'set':
                 return $this->set($property, $arguments);
             case 'get':
                 return $this->get($property);
             case 'add':
                 return $this->add($property, $arguments);
         }
     }
     throw new \RuntimeException('Call to undefined method ' . __CLASS__ . '::' . $name . '()');
 }
Esempio n. 2
0
use PayBreak\Foundation\AbstractEntity;
use PayBreak\Foundation\Helpers\NameHelper;
$names = [AbstractEntity::TYPE_ARRAY => 'array', AbstractEntity::TYPE_INT => 'int', AbstractEntity::TYPE_STRING => 'string', AbstractEntity::TYPE_BOOL => 'bool', AbstractEntity::TYPE_FLOAT => 'float'];
if (count($argv) !== 2) {
    echo 'Argument not supplied!' . "\n";
    die;
}
if (strpos($argv[1], '--class=') !== false) {
    $class = (string) str_replace('--class=', '', $argv[1]);
    if (!class_exists($class)) {
        echo "Class doesn't exist \n";
        die;
    }
    $ref = new ReflectionClass($class);
    $property = $ref->getProperty('properties');
    $property->setAccessible(true);
    $array = $property->getValue(new $class());
} else {
    $array = [];
}
foreach ($array as $k => $v) {
    if (is_numeric($v)) {
        $v = $names[$v];
    }
    if (is_numeric($k)) {
        $k = $v;
        $v = 'mixed';
    }
    echo ' * @method $this set' . NameHelper::snakeToCamel($k) . '(' . $v . ' $' . NameHelper::snakeToCamel($k, true) . ')' . "\n";
    echo ' * @method ' . $v . '|null get' . NameHelper::snakeToCamel($k) . '()' . "\n";
}