public function testContains()
 {
     $string = new String("Test5");
     $this->assertTrue($string->contains("e"));
     $this->assertFalse($string->contains("X"));
     $this->assertTrue($string->contains("E", true));
     $this->assertFalse($string->contains("E", false));
 }
 /**
  * Performs te closure of the session of a project.<br>
  * @param string $project The name of the current project
  */
 public static function close($project)
 {
     $this->activate();
     reset($_SESSION);
     while (list($key, $val) = each($_SESSION)) {
         if (String::contains($key, $project)) {
             $this->deleteValue($key);
         }
     }
     reset($_SESSION);
 }
/**
 * @param mixed $value_
 * @param string $pattern_
 *
 * @return boolean|false If given array/string does contain given pattern.
 */
function assertNotContains($value_, $pattern_)
{
    $message = Assertion_Helper::getMessage('Expected any type not containing a key/value matching given pattern', __FUNCTION__, func_get_args());
    if (is_array($value_)) {
        if (false !== Arrays::containsKeyBySubstring($value_, $pattern_, Arrays::RECURSIVE) || false !== Arrays::containsValueBySubstring($value_, $pattern_, Arrays::RECURSIVE)) {
            Assertion_Context::current()->add(__FUNCTION__, false, $message);
            return false;
        }
    } else {
        if (String::contains($value_, $pattern_)) {
            Assertion_Context::current()->add(__FUNCTION__, false, $message);
            return false;
        }
    }
    Assertion_Context::current()->add(__FUNCTION__, true, $message);
    return true;
}
 public static function containsValueBySubstring(array $array_, $substring_, $mode_ = 3, array &$parentKeys_ = [])
 {
     $exists = false;
     $nestedArrays = [];
     $recursive = Bitmask::hasBitForBitmask($mode_, self::RECURSIVE);
     // search current level
     foreach ($array_ as $key => $value) {
         if (is_array($value)) {
             $nestedArrays[] = $key;
         } else {
             if (false === $exists) {
                 $exists = String::contains($value, $substring_);
                 if (false !== $exists) {
                     $exists = $key;
                     if (false === $recursive) {
                         return $exists;
                     }
                 }
             }
         }
     }
     if (false === $recursive) {
         return $exists;
     }
     // proceed with nested levels if requested
     foreach ($nestedArrays as $nestedArray) {
         $exists = self::containsValueBySubstring($array_[$nestedArray], $substring_, $mode_, $parentKeys_);
         if (false !== $exists) {
             array_unshift($parentKeys_, $nestedArray);
             return $exists;
         }
     }
     return $exists;
 }
 public function contains()
 {
     $str = new String('H�llo');
     $this->assertTrue($str->contains('H'));
     $this->assertTrue($str->contains('�'));
     $this->assertTrue($str->contains('o'));
     $this->assertFalse($str->contains(''));
     $this->assertFalse($str->contains('4'));
 }
Exemple #6
0
 /**
  * A faster/less memory substitute for strstr() or preg_match
  * used to check the occurrence of a subject in a string.
  *
  * @param string $needle
  * @param array $haystack
  * @return bool
  **/
 public static function inString($needle, $haystack)
 {
     return String::contains($needle, $haystack);
 }
Exemple #7
0
include('lib/Common.java.php');
include('lib/System.java.php');
include('lib/String.java.php');
include('lib/File.java.php');

// Initialize a String
$hello = new String("World");

// Show it lowercase
out::prntln("Lowercase of '{$hello->toString()}': " . $hello->toLowerCase());

// Show the string's equality without case
out::prntln("EqualsIgnoreCase test against 'world': " . (($hello->equalsIgnoreCase("world")) ? 'true' : 'false'));

// Show the string's containment for "e"
out::prntln("Contains 'e'? " . (($hello->contains("e")) ? 'true' : 'false'));

// Show the last index of o
out::prntln("Last index of 'o': " . ((!$hello->lastIndexOf("o")) ? 'false' :  $hello->lastIndexOf("o")));

// ----------------------------------------------------- //

// New Section
out::prntln();

// ----------------------------------------------------- //

// Initialize a File
$file = new File("index.php");

// Get the name
<?php 
include_once $_SERVER['DOCUMENT_ROOT'] . "/LIB/libMySQL.php";
include $_SERVER['DOCUMENT_ROOT'] . 'KhunluungramnerkP/loginMySQL.php';
$handler = new MySQLHandler('localhost', 'khunluungramnerk', $usrDB["user"], $usrDB["passwd"]);
$handler->conn();
$getPalabra = array("tipo" => "SELECT", "campos" => array("id, palabra_et, posición, raíz"), "tablas" => "etim_raiz");
$handler->query($getPalabra);
foreach ($handler->data->lista as $etimología) {
    var_dump($etimología);
    $id = $etimología["id"];
    $RaizCompuesta = new String($etimología["raíz"]);
    if ($RaizCompuesta->contains('-')) {
        $RaizCompuesta = explode('-', $RaizCompuesta->get());
        $RaizCompuesta[1] = '-' . $RaizCompuesta[1];
        $primer = new String($RaizCompuesta[0]);
        if ($primer->equals('')) {
            unset($RaizCompuesta[0]);
        }
    } elseif ($RaizCompuesta->contains('+')) {
        $RaizCompuesta = explode('+', $RaizCompuesta->get());
    }
    var_dump($RaizCompuesta);
    $elimRaizPrevia = array("tipo" => "DELETE", "tabla" => "etim_raiz", "condicion" => array("id" => $id));
    $handler->query($elimRaizPrevia);
    $i = 1;
    foreach ($RaizCompuesta as $raiz) {
        $insertRaiz = array("tipo" => "INSERT", "campos" => array("id" => $id, "posición" => $i, "raíz" => $raiz), "tabla" => "etim_raiz");
        $handler->query($insertRaiz);
        $i++;
    }
}