Exemple #1
0
 public function testTail()
 {
     $this->assertEquals('stringtail', \r8\str\tail('string', 'tail'));
     $this->assertEquals('stringtail', \r8\str\tail('stringtail', 'tail'));
     $this->assertEquals('stringtail', \r8\str\tail('string', 'tail', TRUE));
     $this->assertEquals('stringtail', \r8\str\tail('stringtail', 'tail', TRUE));
     $this->assertEquals('stringtail', \r8\str\tail('string', 'tail', FALSE));
     $this->assertEquals('stringtail', \r8\str\tail('stringtail', 'tail', FALSE));
     $this->assertEquals('stringtailTail', \r8\str\tail('stringtail', 'Tail', FALSE));
     $this->assertEquals('stringTail', \r8\str\tail('stringTail', 'Tail', FALSE));
 }
Exemple #2
0
/**
 * Ensures that the given string is at the beginning and end of a string
 *
 * @param String $string The string being enclosed
 * @param String $enclose The value to be appended and prepended to the string, it it doesn't already exist
 * @param Boolean $ignoreCase Whether the comparison should be case sensitive
 * @return String Returns the string with the head and tail on it
 */
function enclose($string, $enclose, $ignoreCase = TRUE)
{
    return \r8\str\tail(\r8\str\head($string, $enclose, $ignoreCase), $enclose, $ignoreCase);
}