Exemple #1
0
 public function testMin()
 {
     $this->assertEquals(10, Math::max(0, 10));
     $this->assertEquals(10, Math::max(10, 0));
 }
Exemple #2
0
 /**
  * Returns the index within this string of the last occurrence of
  * the specified character.
  *
  * @param   $string string|\PHPJ\Lang\String
  * @param   $fromIndex integer
  *          the index to start the search from. There is no
  *          restriction on the value of {@code fromIndex}. If it is
  *          greater than or equal to the length of this string, it has
  *          the same effect as if it were equal to one less than the
  *          length of this string: this entire string may be searched.
  *          If it is negative, it has the same effect as if it were -1:
  *          -1 is returned.
  * @return  integer
  *          the index of the last occurrence of the character in the
  *          character sequence represented by this object that is less
  *          than or equal to {@code fromIndex}, or {@code -1}
  *          if the character does not occur before that point.
  */
 public function lastIndexOf($string, $fromIndex = null)
 {
     if (null === $fromIndex) {
         $fromIndex = $this->length() - 1;
     }
     $fromIndex = Math::min($fromIndex, $this->length() - 1);
     $value = mb_substr($this->value, 0, $fromIndex + 1);
     $index = mb_strrpos($value, (string) $string);
     if (false === $index || $index > $fromIndex) {
         return -1;
     }
     return $index;
 }