Beispiel #1
0
 public function testIsArray()
 {
     // Arrange
     $a = [1, 2, 3];
     // Act
     $x = __::isArray($a);
     // Assert
     $this->assertEquals(true, $x);
 }
Beispiel #2
0
 public function testIsArray()
 {
     $array = [1, 2, 3];
     $this->assertEquals(__::isArray($array), true);
 }
 public function testIsArray()
 {
     // from js
     $this->assertTrue(__::isArray(array(1, 2, 3)), 'arrays are');
     // extra
     $this->assertFalse(__::isArray(null));
     $this->assertTrue(__::isArray(array()));
     $this->assertTrue(__::isArray(array(array(1, 2))));
     $this->assertFalse(__(null)->isArray());
     $this->assertTrue(__(array())->isArray());
     // docs
     $this->assertTrue(__::isArray(array(1, 2)));
     $this->assertFalse(__::isArray((object) array(1, 2)));
 }
  This script provides single phonetic transcriptions as downloads in textfiles.
*/
//Checking if all expected parameters are given:
$params = array('word', 'language', 'study', 'n');
foreach ($params as $p) {
    if (!array_key_exists($p, $_GET)) {
        die('The following parameters must be supplied: ' . implode(', ', $params));
    }
}
//Setup:
chdir('..');
require_once 'config.php';
//Transcription to work with:
$ts = DataProvider::getTranscriptions($_GET['study']);
$ts = $ts[$_GET['language'] . $_GET['word']];
//The Phonetic:
$ps = $ts['Phonetic'];
if (__::isArray($ps)) {
    $n = preg_match('/^\\d+$/', $_GET['n']) ? $_GET['n'] : 0;
    if ($n >= count($ps)) {
        die('Sorry, cannot deliver n=' . $n . ' for values: ' . implode(', ', $ts));
    } else {
        $ps = $ps[$n];
    }
}
//Figuring out the filename:
$file = preg_replace('/mp3/', 'txt', basename(current($ts['soundPaths'])));
//Delivering the content:
header('Content-Type: text/plain; charset=utf-8');
header('Content-Disposition: attachment;filename="' . $file . '"');
echo $ps;