public static function rotate($n) { $s = SayHello::world(); static $letters = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz'; $n = (int) $n % 26; if (!$n) { return $s; } if ($n < 0) { $n += 26; } if ($n == 13) { return str_rot13($s); } $rep = substr($letters, $n * 2) . substr($letters, 0, $n * 2); return strtr($s, $letters, $rep); }
public function testWorld() { $output = SayHello::world(); $this->assertEquals("Hello World, Composer!", $output, "Failed to say hello to the world"); }
<?php require_once __DIR__ . '/../vendor/autoload.php'; // Autoload files using Composer autoload use HelloWorld\SayHello; echo SayHello::world();
<?php require_once __DIR__ . '/../vendor/autoload.php'; // Autoload files using Composer autoload use HelloWorld\Calculator; use HelloWorld\SayHello; // echo SayHello::world(); echo 'Hasilnya : ' . Calculator::tambah(10, 10) . ' jawabannya: ' . SayHello::world(10);
public function testNotMisspelled() { $output = SayHello::world(); $this->assertContains('Composer', $output, "Composer is misspelt"); }