/**
  * Create a uppercase facade name if is not already.
  *
  * @param string $staticName
  *
  * @return string
  */
 public function getStaticProxyNameFromInput(string $staticName) : string
 {
     if ($this->isUppercase($staticName)) {
         return $staticName;
     }
     return ucfirst((string) Str::camelize(strtolower($staticName)));
 }
 /**
  * Make the connection instance.
  *
  * @param array $config
  *
  * @throws \InvalidArgumentException
  *
  * @return mixed
  */
 public function createConnection(array $config)
 {
     $method = 'create' . Str::studly($config['name']) . 'Connection';
     if (isset($this->extensions[$config['name']])) {
         return $this->callCustomCreator($config['name'], $config);
     } elseif (method_exists($this, $method)) {
         return $this->{$method}($config);
     }
     throw new InvalidArgumentException(sprintf('Connection [%s] not supported.', $config['name']));
 }
Пример #3
0
 /**
  * Get a new, random session ID.
  *
  * @return string
  */
 protected function generateSessionId() : string
 {
     return hash('ripemd160', uniqid(Str::random(23), true) . Str::random(25) . microtime(true));
 }
Пример #4
0
 /**
  * Get the extension used by the view file.
  *
  * @param string $path
  *
  * @return string|null
  */
 protected function getExtension(string $path)
 {
     $extensions = array_keys($this->extensions);
     return Arr::first($extensions, function ($key, $value) use($path) {
         return Str::endsWith($path, $value);
     });
 }
Пример #5
0
 public function testStudlyCase()
 {
     //StudlyCase <=> PascalCase
     $this->assertEquals('FooBar', Str::studly('Foo Bar'));
     $this->assertEquals('FooBar', Str::studly('foo bar'));
     $this->assertEquals('FooBar', Str::studly('FooBar'));
     $this->assertEquals('FooBar', Str::studly('fooBar'));
     $this->assertEquals('FooBar', Str::studly('foo-bar'));
     $this->assertEquals('FooBar', Str::studly('foo_bar'));
     $this->assertEquals('FooBar', Str::studly('FOO_BAR'));
     $this->assertEquals('FooBar', Str::studly('foo_bar'));
     $this->assertEquals('FooBar', Str::studly('foo_bar'));
     // test cache
     $this->assertEquals('FooBarBaz', Str::studly('foo-barBaz'));
     $this->assertEquals('FooBarBaz', Str::studly('foo-bar_baz'));
 }
Пример #6
0
 /**
  * Dynamically bind parameters to the view.
  *
  * @param string $method
  * @param array  $parameters
  *
  * @throws \BadMethodCallException
  *
  * @return \Viserio\View\View
  */
 public function __call(string $method, array $parameters) : ViewContract
 {
     if (Str::startsWith($method, 'with')) {
         return $this->with(Str::snake(substr($method, 4)), $parameters[0]);
     }
     throw new BadMethodCallException(sprintf('Method [%s] does not exist on view.', $method));
 }
Пример #7
0
 /**
  * Parse options.
  *
  * @param string $token
  *
  * @return \Viserio\Console\Input\InputOption
  */
 protected function parseOption(string $token) : InputOption
 {
     $token = trim($token, '[]');
     // Shortcut [-y|--yell]
     if (strpos($token, '|') !== false) {
         list($shortcut, $token) = explode('|', $token, 2);
         $shortcut = ltrim($shortcut, '-');
     } else {
         $shortcut = null;
     }
     $name = ltrim($token, '-');
     if (Str::endsWith($token, '=]*')) {
         $mode = InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY;
         $name = substr($name, 0, -3);
     } elseif (Str::endsWith($token, '=')) {
         $mode = InputOption::VALUE_REQUIRED;
         $name = rtrim($name, '=');
     } else {
         $mode = InputOption::VALUE_NONE;
     }
     return new InputOption($name, $shortcut, $mode);
 }
Пример #8
0
 /**
  * Get a random ID string.
  *
  * @return string
  */
 protected function getRandomId() : string
 {
     return Str::random(32);
 }
Пример #9
0
 /**
  * Get the environment argument from the console.
  *
  * @param array $args
  *
  * @return string|null
  */
 protected function getEnvironmentArgument(array $args)
 {
     return Arr::first($args, function ($k, $v) {
         return Str::startsWith($v, '--env');
     });
 }