mirror of
https://github.com/danielstjules/Stringy.git
synced 2025-08-13 08:44:01 +02:00
Merge pull request #59 from usernam3/master
Typecast comparison in startsWith/endsWith
This commit is contained in:
@@ -646,7 +646,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
|
|||||||
$startOfStr = mb_strtolower($startOfStr, $this->encoding);
|
$startOfStr = mb_strtolower($startOfStr, $this->encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $substring === $startOfStr;
|
return (string) $substring === $startOfStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -671,7 +671,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
|
|||||||
$endOfStr = mb_strtolower($endOfStr, $this->encoding);
|
$endOfStr = mb_strtolower($endOfStr, $this->encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $substring === $endOfStr;
|
return (string) $substring === $endOfStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Stringy\Stringy;
|
||||||
|
|
||||||
abstract class CommonTest extends PHPUnit_Framework_TestCase
|
abstract class CommonTest extends PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -756,6 +758,8 @@ abstract class CommonTest extends PHPUnit_Framework_TestCase
|
|||||||
array('bar', 'foo bar', 'foo '),
|
array('bar', 'foo bar', 'foo '),
|
||||||
array('foo bar', 'foo bar', 'oo'),
|
array('foo bar', 'foo bar', 'oo'),
|
||||||
array('foo bar', 'foo bar', 'oo bar'),
|
array('foo bar', 'foo bar', 'oo bar'),
|
||||||
|
array('oo bar', 'foo bar', Stringy::create('foo bar')->first(1), 'UTF-8'),
|
||||||
|
array('oo bar', 'foo bar', Stringy::create('foo bar')->at(0), 'UTF-8'),
|
||||||
array('fòô bàř', 'fòô bàř', '', 'UTF-8'),
|
array('fòô bàř', 'fòô bàř', '', 'UTF-8'),
|
||||||
array('òô bàř', 'fòô bàř', 'f', 'UTF-8'),
|
array('òô bàř', 'fòô bàř', 'f', 'UTF-8'),
|
||||||
array('bàř', 'fòô bàř', 'fòô ', 'UTF-8'),
|
array('bàř', 'fòô bàř', 'fòô ', 'UTF-8'),
|
||||||
@@ -772,6 +776,8 @@ abstract class CommonTest extends PHPUnit_Framework_TestCase
|
|||||||
array('foo', 'foo bar', ' bar'),
|
array('foo', 'foo bar', ' bar'),
|
||||||
array('foo bar', 'foo bar', 'ba'),
|
array('foo bar', 'foo bar', 'ba'),
|
||||||
array('foo bar', 'foo bar', 'foo ba'),
|
array('foo bar', 'foo bar', 'foo ba'),
|
||||||
|
array('foo ba', 'foo bar', Stringy::create('foo bar')->last(1), 'UTF-8'),
|
||||||
|
array('foo ba', 'foo bar', Stringy::create('foo bar')->at(6), 'UTF-8'),
|
||||||
array('fòô bàř', 'fòô bàř', '', 'UTF-8'),
|
array('fòô bàř', 'fòô bàř', '', 'UTF-8'),
|
||||||
array('fòô bà', 'fòô bàř', 'ř', 'UTF-8'),
|
array('fòô bà', 'fòô bàř', 'ř', 'UTF-8'),
|
||||||
array('fòô', 'fòô bàř', ' bàř', 'UTF-8'),
|
array('fòô', 'fòô bàř', ' bàř', 'UTF-8'),
|
||||||
|
Reference in New Issue
Block a user