private function _setupTableNameReplacement()
 {
     $tableName = $this->tableInfo->tableName;
     $defaultTableName = Strings::tableize($this->className);
     $placeholderTableName = $tableName != $defaultTableName ? $tableName : '';
     $this->classStub->addTableSetupItem('table', $placeholderTableName);
 }
Beispiel #2
0
 public function bind($className, $name = '')
 {
     $className = Strings::prependIfMissing($className, '\\');
     $binder = new Binder($className, $name);
     $this->binders[$className . '_' . $name] = $binder;
     return $binder;
 }
Beispiel #3
0
 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();
 }
Beispiel #5
0
 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;
 }
Beispiel #7
0
 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);
 }
Beispiel #8
0
 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();
 }
Beispiel #9
0
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;
}
Beispiel #10
0
 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;
 }
Beispiel #11
0
 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;
 }
Beispiel #12
0
 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();
 }
Beispiel #14
0
 private function _removePrefix($string)
 {
     return Strings::removePrefix($string, self::_prefixSystem());
 }
Beispiel #15
0
 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 : '';
 }
Beispiel #16
0
 /**
  * @test
  */
 public function shouldIntegerEndWithInteger()
 {
     $this->assertTrue(Strings::endsWith(1231, 31));
 }
Beispiel #17
0
 public static function addPrefixIfNeeded($url)
 {
     $prefix = Config::getValue('global', 'prefix_system');
     $url = Strings::removePrefix($url, $prefix);
     return $prefix . $url;
 }
Beispiel #18
0
 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);
 }
Beispiel #20
0
 /**
  * @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(), '__');
 }
Beispiel #21
0
 public static function getMessageWithHttpProtocol($code, $protocol = 'HTTP/1.1 ')
 {
     return Strings::appendPrefix(self::getMessage($code), $protocol);
 }
Beispiel #22
0
 public static function startsWith($prefix)
 {
     return function ($string) use($prefix) {
         return Strings::startsWith($string, $prefix);
     };
 }
Beispiel #23
0
 private function _objectName()
 {
     return Strings::camelCaseToUnderscore($this->_object->getModelName());
 }
Beispiel #24
0
 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;
         }
     }
 }
Beispiel #25
0
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>';
}
Beispiel #26
0
 public function getGeneratedFunctions()
 {
     return trim(Strings::sprintAssoc($this->_generatedFunctions, array('INDENT' => self::INDENT)));
 }
Beispiel #27
0
 public function isEmpty()
 {
     return Strings::isBlank($this->sql);
 }
Beispiel #28
0
 public static function endsWith($suffix)
 {
     return function ($string) use($suffix) {
         return Strings::endsWith($string, $suffix);
     };
 }
Beispiel #29
0
 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');
 }