当前位置: 首页>>代码示例>>PHP>>正文


PHP Stringy::create方法代码示例

本文整理汇总了PHP中Stringy\Stringy::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Stringy::create方法的具体用法?PHP Stringy::create怎么用?PHP Stringy::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Stringy\Stringy的用法示例。


在下文中一共展示了Stringy::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generate

 /**
  * Generate the full registry string.
  *
  * @return string
  */
 protected function generate()
 {
     $this->resultString = Stringy::create('');
     /*
      * @var Field
      */
     foreach ($this->values as $valueName => $valueClass) {
         $this->resultString = $this->resultString->append($valueClass->getValue());
     }
     return (string) $this->resultString;
 }
开发者ID:convenia,项目名称:ticket-order,代码行数:16,代码来源:Registry.php

示例2: checkType

 /**
  * @param string $type
  */
 protected function checkType($type = '')
 {
     if (!$type) {
         throw new \BadMethodCallException(self::EXCEPTION_SCHEMA_TYPE_REQUIRED);
     }
     if (Stringy::create(substr($type, 0, 1))->isLowerCase()) {
         throw new \InvalidArgumentException(self::EXCEPTION_SCHEMA_TYPE_INVALID . ': ' . $type);
     }
 }
开发者ID:nypl,项目名称:schemabuilder,代码行数:12,代码来源:Schema.php

示例3: short

 /**
  * Returns the shortened version of this name.
  *
  * @return string
  */
 public function short()
 {
     $shortened_parts = [];
     foreach ($this->segments as $part) {
         $string = S::create($part);
         if ($string->contains('.')) {
             $shortened_parts[] = $string;
         } else {
             $shortened_parts[] = $string->truncate(2, '.');
         }
     }
     return implode(' ', $shortened_parts);
 }
开发者ID:enzyme,项目名称:name,代码行数:18,代码来源:Part.php

示例4: getCommandName

 protected function getCommandName()
 {
     $commandName = '';
     $namespace = $this->getNamespace();
     if (isset($namespace)) {
         $namespace = preg_replace('/(?<=\\w)(?=[A-Z])/', " \$1", $this->getNamespace());
         foreach (explode('\\', $namespace) as $item) {
             $commandName .= Stringy::create($item)->slugify()->__toString() . ':';
         }
     }
     $className = preg_replace('/(?<=\\w)(?=[A-Z])/', " \$1", $this->getClassName());
     $commandName .= Stringy::create($className)->slugify()->__toString();
     return $commandName;
 }
开发者ID:Festiv,项目名称:Festiv,代码行数:14,代码来源:Command.php

示例5: getInitial

 public function getInitial()
 {
     $words = new Collection(explode(' ', $this->name));
     // if name contains single word, use first N character
     if ($words->count() === 1) {
         if ($this->name->length() >= $this->length) {
             return $this->name->substr(0, $this->length);
         }
         return (string) $words->first();
     }
     // otherwise, use initial char from each word
     $initials = new Collection();
     $words->each(function ($word) use($initials) {
         $initials->push(Stringy::create($word)->substr(0, 1));
     });
     return $initials->slice(0, $this->length)->implode('');
 }
开发者ID:explore-laravel,项目名称:avatar,代码行数:17,代码来源:InitialGenerator.php

示例6: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     try {
         $helper = $this->getHelper('question');
         $question = new Question('Please enter the login : ', '');
         $login = $helper->ask($input, $output, $question);
         if ($login == "") {
             throw new \Exception("you must specify login");
         }
         // récupération de la config securité
         $values = \Parameters::get('security');
         $class = $values['security']['classes'];
         $ss = new $class(new Session(), new Request());
         // get user instance
         $user = $ss->userFromLogin($login);
         if ($user == null) {
             throw new \Exception("User {$login} doesn't exist");
         }
         $iduser = $user->id;
         // get all roles
         $roles = $ss->getRoles();
         $strRole = "[";
         foreach ($roles as $role) {
             if ($strRole != "[") {
                 $strRole .= ",";
             }
             $strRole .= $role->role;
         }
         $strRole .= "]";
         $question = new Question('Add roles for ' . $login . ' ' . $strRole . ', type role separated by comma : ', '');
         $roles = $helper->ask($input, $output, $question);
         $output->writeln('Add roles to user');
         if ($roles != "" && $iduser != null) {
             $rolea = \Stringy\Stringy::create($roles)->split(",");
             foreach ($rolea as $role) {
                 $roles = $ss->getRolesFromName(array($role));
                 $role1 = $roles->first();
                 $ss->addUserToRole($iduser, $role1->id);
             }
         }
     } catch (\Exception $e) {
         $output->writeln('Error : ' . $e->getMessage());
     }
     $output->writeln('finished');
 }
开发者ID:kletellier,项目名称:mvc,代码行数:45,代码来源:UserRoleCommand.php

示例7: render

 public function render($str = false)
 {
     if (!$str) {
         $str = isset($this->arguments['str']) ? $this->arguments['str'] : '';
     }
     $str = isset($this->arguments['str']) ? $this->arguments['str'] : '';
     return S::create($str)->tidy();
 }
开发者ID:blypo,项目名称:blypo,代码行数:8,代码来源:Tidy.php

示例8: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     try {
         $helper = $this->getHelper('question');
         $question = new Question('Please enter the login : ', '');
         $login = $helper->ask($input, $output, $question);
         if ($login == "") {
             throw new \Exception("you must specify login");
         }
         $question = new Question('Please enter the mail : ', '');
         $email = $helper->ask($input, $output, $question);
         if ($email == "") {
             throw new \Exception("you must specify a mail");
         }
         $question = new Question('Please enter the password : ', '');
         $password = $helper->ask($input, $output, $question);
         if ($password == "") {
             throw new \Exception("you must specify a password");
         }
         // récupération de la config securité
         $values = \Parameters::get('security');
         $class = $values['security']['classes'];
         $ss = new $class(new Session(), new Request());
         if ($ss->emailExist($email)) {
             throw new \Exception("Email already exists.");
         }
         if ($ss->loginExist($login)) {
             throw new \Exception("Login already exists.");
         }
         // get all roles
         $roles = $ss->getRoles();
         $strRole = "[";
         foreach ($roles as $role) {
             if ($strRole != "[") {
                 $strRole .= ",";
             }
             $strRole .= $role->role;
         }
         $strRole .= "]";
         $question = new Question('Add roles for this user ' . $strRole . ', type role separated by comma : ', '');
         $roles = $helper->ask($input, $output, $question);
         $output->writeln('Create user');
         $ret = $ss->userCreate($login, $email, $password);
         if ($roles != "" && $ret != null) {
             $rolea = \Stringy\Stringy::create($roles)->split(",");
             foreach ($rolea as $role) {
                 $roles = $ss->getRolesFromName(array($role));
                 $role1 = $roles->first();
                 $ss->addUserToRole($ret, $role1->id);
             }
         }
     } catch (\Exception $e) {
         $output->writeln('Error : ' . $e->getMessage());
     }
     $output->writeln('finished');
 }
开发者ID:kletellier,项目名称:mvc,代码行数:56,代码来源:UserCommand.php

示例9: distributeResources

 public function distributeResources($resources, $componentPrefixedKey = 'LogicalResourceId')
 {
     Log::debug(__METHOD__ . ' start');
     $groupedResourceCollection = [];
     foreach ($this->items as $componentKey => $component) {
         foreach ($resources as $resourceKey => $resource) {
             if (Stringy::create($resource[$componentPrefixedKey])->startsWith(studly_case($componentKey), false)) {
                 $groupedResourceCollection[$componentKey][] = $resource;
                 unset($resources[$resourceKey]);
             }
             if ($resource[$componentPrefixedKey] == data_get($resource, 'StackName') or $resource[$componentPrefixedKey] == '') {
                 $groupedResourceCollection['_stack'][] = $resource;
                 unset($resources[$resourceKey]);
             }
         }
     }
     if (count($resources) > 0) {
         $groupedResourceCollection['_ungrouped'] = $resources;
     }
     $groupedResourceCollectionKeys = array_keys($groupedResourceCollection);
     $retval = Collection::make($groupedResourceCollection)->map(function ($resources) {
         return Collection::make($resources);
     })->replaceKeys(function ($k) use($groupedResourceCollectionKeys) {
         return $groupedResourceCollectionKeys[$k];
     });
     Log::debug(__METHOD__ . ' end');
     return $retval;
 }
开发者ID:sourcestream,项目名称:highcore-api,代码行数:28,代码来源:ComponentCollection.php

示例10: validate

 /**
  * @param array $data
  *
  * @throws ValidatorException
  * @throws ValidatorInvalidRuleException
  */
 public function validate(array $data)
 {
     if (count($this->rules) === 0) {
         return;
     }
     foreach ($this->rules as $ruleIndex => $rules) {
         foreach ($rules as $rule) {
             if (strpos($rule, ':') !== false) {
                 list($composeRuleIndex, $composeRuleParams) = explode(':', $rule);
                 $methodName = Stringy::create($composeRuleIndex);
                 $methodName = (string) $methodName->toTitleCase();
                 $this->methodExists($methodName);
                 $valid = $this->{'validate' . $methodName}($data, $ruleIndex, $composeRuleParams);
                 $this->shouldStop($valid, $composeRuleIndex, $ruleIndex, $data);
                 continue;
             }
             $methodName = Stringy::create($rule);
             $methodName = (string) $methodName->toTitleCase();
             $this->methodExists($methodName);
             $valid = $this->{'validate' . $methodName}($data, $ruleIndex);
             $this->shouldStop($valid, $rule, $ruleIndex, $data);
         }
     }
 }
开发者ID:convenia,项目名称:ticket-order,代码行数:30,代码来源:Validation.php

示例11: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     try {
         $helper = $this->getHelper('question');
         $question = new Question('Please enter the role key : ', '');
         $role = $helper->ask($input, $output, $question);
         if ($role == "") {
             throw new \Exception("you must specify role key");
         }
         $roles = \Stringy\Stringy::create($role)->slugify();
         $question = new Question('Please enter the role description : ', '');
         $description = $helper->ask($input, $output, $question);
         if ($description == "") {
             throw new \Exception("you must specify a description");
         }
         // récupération de la config securité
         $values = \Parameters::get('security');
         $class = $values['security']['classes'];
         $ss = new $class(new Session(), new Request());
         $output->writeln('Create role');
         $ss->roleCreate($roles, $description);
     } catch (\Exception $e) {
         $output->writeln('Error : ' . $e->getMessage());
     }
     $output->writeln('finished');
 }
开发者ID:kletellier,项目名称:mvc,代码行数:26,代码来源:RoleCommand.php

示例12: getResourceName

 protected function getResourceName(InputInterface $input, OutputInterface $output)
 {
     $description = $input->getArgument('description');
     if (!$description) {
         $dialog = $this->getHelper('dialog');
         $description = $dialog->ask($output, 'Description for this migration: ');
     }
     $this->migration_description = str_replace("'", "\\'", $description);
     return 'Migration' . date('YmdHis') . Stringy::create($description)->slugify()->upperCamelize();
 }
开发者ID:glynnforrest,项目名称:neptune,代码行数:10,代码来源:CreateMigrationCommand.php

示例13: stringFilter

 public function stringFilter($action, $data, array $options = array())
 {
     if ($action == null) {
         return;
     }
     $customManipulators = ["cosgrove"];
     //plans for custom manipulator functions
     switch (true) {
         case in_array($action, $customManipulators):
             //Plans for custom manipulator functions
             break;
         default:
             return call_user_func_array(array(Stringy::create($data), $action), $options);
     }
 }
开发者ID:getgrav,项目名称:grav-plugin-filter-strings,代码行数:15,代码来源:FilterStringsTwigExtension.php

示例14: __construct

 /**
  * @param Plugin $plugin
  */
 public function __construct(Plugin $plugin)
 {
     parent::__construct($plugin);
     $this->pluginBaseDir = dirname($plugin->getFilePath());
     $this->pluginBaseDirRel = preg_replace('/^' . preg_quote(ABSPATH, '/') . '/', '', $this->pluginBaseDir);
     $uploadsData = wp_upload_dir();
     $this->uploadsBaseDir = isset($uploadsData['basedir']) ? $uploadsData['basedir'] . '/' . $plugin->getSlug() : $this->pluginBaseDir . '/uploads';
     $logFileName = Stringy::create($plugin->getName());
     $this->logFilePath = $this->uploadsBaseDir . '/log/' . (string) $logFileName->camelize() . '.log';
     $templatePluginSlugDir = get_template_directory() . '/' . $plugin->getSlug();
     /* @var FcrHooks $hookFactory */
     $hookFactory = $this->plugin->getHookFactory();
     $this->whereTemplatesMayReside = array($templatePluginSlugDir, $this->pluginBaseDir . '/templates');
     $this->whereTemplatesMayResideFilter = $hookFactory->getWhereTemplatesMayResideFilter();
     $this->whereScriptsMayReside = array($templatePluginSlugDir . '/js', $this->pluginBaseDir . '/assets/js');
     $this->whereScriptsMayResideFilter = $hookFactory->getWhereScriptsMayResideFilter();
     $this->whereStylesMayReside = array($templatePluginSlugDir . '/css', $this->pluginBaseDir . '/assets/css');
     $this->whereStylesMayResideFilter = $hookFactory->getWhereStylesMayResideFilter(array());
 }
开发者ID:panvagenas,项目名称:wp-plugin-core,代码行数:22,代码来源:Paths.php

示例15: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $fs = new Filesystem();
     try {
         Capsule::connection("default")->setFetchMode(PDO::FETCH_NUM);
         $arr = Capsule::connection("default")->select('SHOW TABLES;');
         foreach ($arr as $ts) {
             $name = $ts[0];
             $output->writeln($name);
             // search for primary
             $sql1 = "SHOW INDEX from " . $name . " WHERE Key_name='PRIMARY';";
             $pk1 = Capsule::connection("default")->select($sql1);
             if (count($pk1) > 0) {
                 $pk = $pk1[0][4];
             } else {
                 // by first unique index
                 $sql2 = "SHOW INDEX from " . $name . " WHERE Non_unique=0;";
                 $pk2 = Capsule::connection("default")->select($sql2);
                 if (count($pk2) > 0) {
                     $pk = $pk2[0][4];
                 }
             }
             $modelname = Stringy::create($name)->upperCamelize()->__toString();
             $nmodel = $this->model;
             $nmodel = str_replace('##modelname##', $modelname, $nmodel);
             $nmodel = str_replace('##tablename##', $name, $nmodel);
             $nmodel = str_replace('##foreignkey##', $pk, $nmodel);
             $path = ROOT . DS . "app" . DS . "Application" . DS . "Models" . DS;
             $filename = $path . $modelname . ".php";
             file_put_contents($filename, $nmodel);
         }
     } catch (\Exception $e) {
         $output->writeln('Error : ' . $e->getMessage());
     }
     $output->writeln('finished');
 }
开发者ID:kletellier,项目名称:mvc,代码行数:36,代码来源:ModelsCommand.php


注:本文中的Stringy\Stringy::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。