Esempio n. 1
0
 public function test_get()
 {
     $data = [['name' => 'foo', 'type' => 'test'], ['name' => 'bar', 'type' => 'test'], (object) ['name' => 'baz'], [1, 2, 3]];
     $nameOf = F\get('name');
     $this->assertEquals(['name' => 'foo', 'type' => 'test'], F\get(0, $data));
     $this->assertEquals('bar', $nameOf($data[1]));
     $this->assertEquals('baz', $nameOf($data[2]));
     $this->assertEquals(null, $nameOf($data[3]));
 }
Esempio n. 2
0
function addContents()
{
    $addContents = function ($name, $parts) {
        $names = F\filter(F\notEq($name), F\map(F\get('name'), $parts));
        var_dump($names);
        $contents = F\map(function ($partname) use($name) {
            $link = URL . "/docs/{$name}.md#{$partname}";
            return "- [{$partname}]({$link})";
        }, $names);
        file_put_contents("docs/README.md", F\join("\n\n", F\concat(["## {$name}"], $contents)) . "\n\n", FILE_APPEND);
        return array_merge(['# ' . $name, '## Table Of Contents'], $contents, F\map(F\get('md'), $parts));
    };
    return F\apply(F\curry($addContents), func_get_args());
}