private function _setupTableNameReplacement() { $tableName = $this->tableInfo->tableName; $defaultTableName = Strings::tableize($this->className); $placeholderTableName = $tableName != $defaultTableName ? $tableName : ''; $this->classStub->addTableSetupItem('table', $placeholderTableName); }
public function bind($className, $name = '') { $className = Strings::prependIfMissing($className, '\\'); $binder = new Binder($className, $name); $this->binders[$className . '_' . $name] = $binder; return $binder; }
public function validateNotBlank($value, $errorMessage, $errorField = null) { if (Strings::isBlank($value)) { $this->error($errorMessage); $this->_errorFields[] = $errorField; } }
public function handle($data) { $method = $data['method']; $restData = Json::decode($data['rest_data']); $class = '\\Tests\\MockSugarServer\\Action\\' . Strings::underscoreToCamelCase($method); $action = new $class($restData); return $action->process()->response(); }
public function getViewName() { $class = Strings::underscoreToCamelCase($this->controller); if (Strings::endsWith($class, 'Controller')) { return Strings::removeSuffix($class, 'Controller'); } return $class; }
public static function match($method) { if (Strings::startsWith($method, 'findBy')) { $dynamicFinder = new self($method); $dynamicFinder->parse(); return $dynamicFinder; } return null; }
public function asString() { $key = $this->timeAgo->getKey(); $params = $this->timeAgo->getParams(); if (Strings::equal($key, 'timeAgo.thisYear')) { $params['month'] = I18n::t($params['month']); } return I18n::t($key, $params); }
public function join() { $any = Arrays::any($this->_query->joinClauses, function (JoinClause $joinClause) { return Strings::equalsIgnoreCase($joinClause->type, 'RIGHT'); }); if ($any) { throw new BadMethodCallException('RIGHT JOIN is not supported in sqlite3'); } return parent::join(); }
function addFile(array $fileInfo = array(), $stringToRemove = '') { if (!empty($fileInfo)) { $prefixSystem = Config::getValue('global', 'prefix_system'); $suffixCache = Config::getValue('global', 'suffix_cache'); $suffixCache = !empty($suffixCache) ? '?' . $suffixCache : ''; $url = $prefixSystem . $fileInfo['params']['url'] . $suffixCache; $url = Strings::remove($url, $stringToRemove); return _getHtmlFileTag($fileInfo['type'], $url); } return null; }
public static function all() { //this implementation is for PHP where function getallheaders() doesn't exists in CLI $headers = array(); foreach ($_SERVER as $name => $value) { if (Strings::startsWith($name, 'HTTP_')) { $headerName = Strings::removePrefix($name, 'HTTP_'); $key = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', $headerName)))); $headers[$key] = $value; } } return $headers; }
public function getMetadata($instance) { $class = new ReflectionClass($instance); $properties = $class->getProperties(); $annotations = array(); foreach ($properties as $property) { $doc = $property->getDocComment(); if (Strings::contains($doc, '@Inject')) { if (preg_match("#@var ([\\\\A-Za-z0-9]*)#s", $doc, $matched)) { $className = $matched[1]; $name = $this->extractName($doc); $annotations[$property->getName()] = array('name' => $name, 'className' => $className); } else { throw new InjectorException('Cannot @Inject dependency. @var is not defined for property $' . $property->getName() . ' in class ' . $class->getName() . '.'); } } } return $annotations; }
private static function isJavaScriptView($viewName) { return Strings::endsWith($viewName, '.js') || Strings::endsWith($viewName, '_js'); }
public static function createModule($moduleName) { $moduleName = ucfirst(Inflector::singularize($moduleName)); $moduleName = Strings::appendPrefix($moduleName, '\\SugarClient\\Module\\'); return new $moduleName(); }
private function _removePrefix($string) { return Strings::removePrefix($string, self::_prefixSystem()); }
public function getName() { $name = Arrays::getValue($this->options, 'as', $this->prepareRuleName()); $nameWithPath = Strings::appendSuffix($name, '_path'); $name = lcfirst(Strings::underscoreToCamelCase($nameWithPath)); return $this->actionRequired ? $name : ''; }
/** * @test */ public function shouldIntegerEndWithInteger() { $this->assertTrue(Strings::endsWith(1231, 31)); }
public static function addPrefixIfNeeded($url) { $prefix = Config::getValue('global', 'prefix_system'); $url = Strings::removePrefix($url, $prefix); return $prefix . $url; }
public function translate($key, $params = array()) { $explodedKey = explode('.', $key); $translation = Arrays::getNestedValue($this->_labels, $explodedKey) ?: $key; return $this->localize(Strings::sprintAssoc($translation, $params)); }
public static function add($name, $path) { $prefixSystem = Config::getValue('global', 'prefix_system'); $pathWithoutPrefix = $prefixSystem ? Strings::removePrefix($path, $prefixSystem) : $path; self::$breadcrumbsMap[] = new self($name, $pathWithoutPrefix); }
/** * @param ReflectionMethod $method * @return bool */ private function canParseMethod(ReflectionMethod $method) { return Strings::contains($method->getDocComment(), '@WebMethod') && $method->isPublic() && !$method->isConstructor() && !$method->isDestructor() && !Strings::contains($method->getName(), '__'); }
public static function getMessageWithHttpProtocol($code, $protocol = 'HTTP/1.1 ') { return Strings::appendPrefix(self::getMessage($code), $protocol); }
public static function startsWith($prefix) { return function ($string) use($prefix) { return Strings::startsWith($string, $prefix); }; }
private function _objectName() { return Strings::camelCaseToUnderscore($this->_object->getModelName()); }
public function nullifyIfEmpty() { $fields = func_get_args(); foreach ($fields as $field) { if (isset($this->{$field}) && !is_bool($this->{$field}) && Strings::isBlank($this->{$field})) { $this->{$field} = null; } } }
function optionTag($value, $name, $current) { $selected = Arrays::findKeyByValue($current, $value) !== false ? 'selected' : ''; $value = Strings::isNotBlank($value) ? ' value="' . $value . '" ' : ' value="" '; return '<option' . $value . $selected . '>' . $name . '</option>'; }
public function getGeneratedFunctions() { return trim(Strings::sprintAssoc($this->_generatedFunctions, array('INDENT' => self::INDENT))); }
public function isEmpty() { return Strings::isBlank($this->sql); }
public static function endsWith($suffix) { return function ($string) use($suffix) { return Strings::endsWith($string, $suffix); }; }
public function getTab() { $noController = Strings::remove(get_called_class(), 'Controller'); $noSlashes = Strings::remove($noController, '\\'); return Strings::camelCaseToUnderscore($noSlashes); }
public static function isReflectionType($types) { return Strings::contains($types, 'className'); }