Overview

Namespaces

  • Deimos
    • Helper
      • Exceptions
      • Helpers
        • Arr
        • Str
      • Traits
  • PHP

Classes

  • Deimos\Helper\AbstractHelper
  • Deimos\Helper\Helper
  • Deimos\Helper\Helpers\Arr\Arr
  • Deimos\Helper\Helpers\Dir
  • Deimos\Helper\Helpers\File
  • Deimos\Helper\Helpers\Json
  • Deimos\Helper\Helpers\Math
  • Deimos\Helper\Helpers\Money
  • Deimos\Helper\Helpers\Str\Str

Interfaces

  • Deimos\Helper\InterfaceHelper
  • Throwable

Traits

  • Deimos\Helper\Helpers\Arr\KeyTrait
  • Deimos\Helper\Helpers\Arr\StackTrait
  • Deimos\Helper\Helpers\Str\DefaultTrait
  • Deimos\Helper\Traits\Helper

Exceptions

  • Deimos\Helper\Exceptions\ExceptionEmpty
  • Exception
  • InvalidArgumentException
  • LogicException
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: namespace Deimos\Helper\Helpers\Str;
  4: 
  5: trait DefaultTrait
  6: {
  7: 
  8:     /**
  9:      * @param string $string
 10:      * @param int    $start
 11:      * @param int    $length
 12:      *
 13:      * @return string
 14:      */
 15:     public function sub($string, $start, $length = null)
 16:     {
 17:         return mb_substr($string, $start, $length);
 18:     }
 19: 
 20:     /**
 21:      * @param string $string
 22:      *
 23:      * @return string
 24:      */
 25:     public function upp($string)
 26:     {
 27:         return mb_convert_case($string, MB_CASE_UPPER);
 28:     }
 29: 
 30:     /**
 31:      * @param string $string
 32:      *
 33:      * @return string
 34:      */
 35:     public function low($string)
 36:     {
 37:         return mb_convert_case($string, MB_CASE_LOWER);
 38:     }
 39: 
 40:     /**
 41:      * @param string $string
 42:      *
 43:      * @return string
 44:      */
 45:     public function capitalize($string)
 46:     {
 47:         return mb_convert_case($string, MB_CASE_TITLE);
 48:     }
 49: 
 50:     /**
 51:      * @param string $string
 52:      *
 53:      * @return string mixed
 54:      */
 55:     public function toNumber($string)
 56:     {
 57:         return preg_replace('/\D/', '', $string);
 58:     }
 59: 
 60:     /**
 61:      * @param $string
 62:      *
 63:      * @return int
 64:      */
 65:     public function len($string)
 66:     {
 67:         return mb_strlen($string);
 68:     }
 69: 
 70:     /**
 71:      * @param string $string
 72:      * @param string $needle
 73:      * @param int    $offset
 74:      *
 75:      * @return int
 76:      */
 77:     public function pos($string, $needle, $offset = null)
 78:     {
 79:         return mb_strpos($string, $needle, $offset);
 80:     }
 81: 
 82:     /**
 83:      * @param string $string
 84:      * @param int    $multiplier
 85:      *
 86:      * @return string
 87:      */
 88:     public function repeat($string, $multiplier)
 89:     {
 90:         return str_repeat($string, $multiplier);
 91:     }
 92: 
 93:     /**
 94:      * @param string $string
 95:      *
 96:      * @return string
 97:      */
 98:     public function shuffle($string)
 99:     {
100:         return $this->rand($string, $this->len($string));
101:     }
102: 
103: }
104: 
API documentation generated by ApiGen