Ejemplo n.º 1
0
 /**
  * Generate a hashid based on random data.
  *
  * @param null $salt
  *
  * @return string
  */
 function generate_hashid($salt = null)
 {
     if (empty($salt)) {
         $salt = config('key');
     }
     $hashids = new Hashids($salt);
     $min = rand(1, 1000) * rand(1, 1000);
     $max = rand(1, 1000) * rand(1, 1000);
     $quantity = rand(1, 64);
     $numbers = unique_random_numbers_within_range($min, $max, $quantity);
     return StaticStringy::truncate(StaticStringy::shuffle($hashids->encode($numbers)), 8);
 }
Ejemplo n.º 2
0
 /**
  * @dataProvider truncateProvider()
  */
 public function testTruncate($expected, $str, $length, $substring = '', $encoding = null)
 {
     $result = S::truncate($str, $length, $substring, $encoding);
     $this->assertInternalType('string', $result);
     $this->assertEquals($expected, $result);
 }
Ejemplo n.º 3
0
 public function truncate($string, $length, $ending = '...')
 {
     return Stringy::truncate($string, $length, $ending);
 }