Esempio n. 1
0
<?php

/**
 * Dieses Script einfach in einer CLI ausführen
 * Ein Webserver ist nicht notwendig.
 *
 * Dieses Script demonstriert den Scalar Typ
 */
include __DIR__ . "/examples-utils.php";
$s = new \PerrysLambda\ScalarProperty("Zähn € zahme Ziegen zögen zwei Zentner Zücker zum Zoö!");
echo "\n";
L::line("Begin");
echo "\n";
L::line($s->toString());
echo "\n";
L::line("Length:", $s->length());
L::line("Begin with \"Zä\":", L::b($s->startsWith("Zä")));
L::line("Begin with \"Ze\":", L::b($s->startsWith("Ze")));
L::line("Ends with \"Zoö!\":", L::b($s->endsWith("Zoö!")));
L::line("Ends with \"Zoo!\":", L::b($s->endsWith("Zoo!")));
L::line("Last 4 chars:", $s->substr(-4));
L::line("Contains \"zögen\":", L::b($s->contains('zögen')));
L::line("Contains \"zogen\":", L::b($s->contains('zogen')));
L::line("Index of \"ö\":", $s->indexOf('ö'));
L::line("Last index of \"ö\":", $s->lastIndexOf('ö'));
echo "\n";
Esempio n. 2
0
$skiptake->each(function (OA $r) {
    L::line($r->agent);
});
echo "------\n";
// sort
$orderedskiptake = $skiptake->order(function (OA $r) {
    return $r->agentScalar->contains('Linux') ? 1 : 0;
})->thenBy(function (OA $r) {
    return $r->agent;
})->toList();
$orderedskiptake->each(function (OA $r) {
    L::line($r->agent);
});
echo "\n";
L::line("Sort by linux / not linux and useragent", $watch->stop()->result());
echo "\n";
// unset
unset($subc);
L::line("Unset \$subc.");
unset($agents);
L::line("Unset \$agents.");
unset($skiptake);
L::line("Unset \$skiptake.");
unset($orderedskiptake);
L::line("Unset \$orderedskiptake.");
unset($collection);
L::line("Unset \$collection.");
unset($grouped);
L::line("Unset \$grouped.");
L::line("Finished. Total time:", $total->stop()->result());
echo "\n";