/** * Logic that will be executed when command is visited * * @param AbstractCommand $command * @param int $depth * * @return mixed */ function process(AbstractCommand $command, $depth = 0) { if (is_null($this->argumentsContainer->getArgumentAt($this->currentIndex + 2))) { echo $command->getArgument() . ' '; } elseif (StaticStringy::startsWith($command->getArgument(), $this->argumentsContainer->getArgumentAt($this->currentIndex + 2))) { echo $command->getArgument() . ' '; } }
/** * @param $name * @param array $arguments * * @throws \ThinFrame\Foundation\Exceptions\InvalidArgumentException * @throws \BadMethodCallException */ public function __call($name, array $arguments) { if (StaticStringy::startsWith($name, 'on')) { $eventId = StaticStringy::camelize(substr($name, 2)); if (!isset($arguments[0]) || !is_callable($arguments[0])) { throw new InvalidArgumentException('Invalid or missing callback for event'); } $priority = isset($arguments[1]) ? intval($arguments[1]) : Priority::LOW; $this->attachTo($eventId, $arguments[0], $priority); } else { throw new \BadMethodCallException('Method ' . $name . ' is not defined under ' . get_called_class()); } }
private function detectTemplateType($template) { if (is_dir($template)) { if (is_dir($this->join($template, '.git'))) { return self::TEMPLATE_TYPE_LOCAL_GIT; } else { return self::TEMPLATE_TYPE_DIR; } } if (Stringy::startsWith($template, 'https') || Stringy::startsWith($template, 'git')) { return self::TEMPLATE_TYPE_REMOTE_GIT; } return self::TEMPLATE_TYPE_UNKNOWN; }
/** * Parse version string * * @throws \ThinFrame\Foundation\Exception\InvalidArgumentException */ private function parseVersion() { if (StaticStringy::startsWith($this->versionString, 'v')) { $this->versionString = StaticStringy::substr($this->versionString, 1); } if (strstr($this->versionString, '-')) { if (sscanf($this->versionString, '%d.%d.%d-%s', $this->major, $this->minor, $this->release, $this->suffix) != 4) { throw new InvalidArgumentException('Invalid version format ' . $this->versionString); } } else { if (sscanf($this->versionString, '%d.%d.%d', $this->major, $this->minor, $this->release) != 3) { throw new InvalidArgumentException('Invalid version format ' . $this->versionString); } } }
private function parseMethodColumnDescriptors(\ReflectionClass $reflClass, &$columnDescriptors, AutoTablesConfiguration $config) { foreach ($reflClass->getMethods() as $method) { $column = null; $annot = $this->reader->getMethodAnnotation($method, '\\twentysteps\\Bundle\\AutoTablesBundle\\Annotations\\Column'); if ($annot) { $column = new MethodColumnDescriptor($method); Ensure::isTrue(count($method->getParameters()) == 0, 'Failed to use [%s] as getter method, only parameterless methods supported for @Column', $method->getName()); Ensure::isTrue(StaticStringy::startsWith($method->getName(), 'get'), 'Illegal method name [%s], getter methods must start with a get prefix', $method->getName()); $column->addAutoTablesAnnotation($annot); $column->addAutoTablesConfig($config, $method->getName()); } if ($column && $column->isUsable()) { $methodName = 'set' . substr($method->getName(), 3); if ($reflClass->hasMethod($methodName)) { $setterMethod = $reflClass->getMethod($methodName); Ensure::isEqual(1, count($setterMethod->getParameters()), 'setter method [%s] needs to have exactly one parameter', $setterMethod->getName()); $column->setSetterMethod($setterMethod); } $column->validate(); $this->columnDescriptorMap[$column->getId()] = $column; $columnDescriptors[] = $column; } } }
/** * @dataProvider startsWithProvider() */ public function testStartsWith($expected, $str, $substring, $caseSensitive = true, $encoding = null) { $result = S::startsWith($str, $substring, $caseSensitive, $encoding); $this->assertInternalType('boolean', $result); $this->assertEquals($expected, $result); }
public function startsWith($string, $subString) { return Stringy::startsWith($string, $subString); }
public function index($value, $params = array()) { return Stringy::startsWith($value, array_get($params, 0), array_get($params, 1, false)); }
/** Определение колонки и порядка сортировки. Возвращает массив [colname, asc] */ public function processOrderColumnFromUrl($column) { // Обратная сортировка if (StaticStringy::startsWith($column, '_')) { $col = StaticStringy::removeLeft($column, '_'); if ($this->checkOrderByOptionExists($col)) { return array($col, false); } } return array($column, true); }