Esempio n. 1
0
 public function test_join()
 {
     $join = F\join(', ');
     $this->assertEquals('foo, bar, baz', $join(['foo', 'bar', 'baz']));
     $this->assertEquals('foo', $join(['foo']));
     $this->assertEquals('', $join([]));
 }
Esempio n. 2
0
 public function test_s()
 {
     $this->assertEquals('Hello World !', F\s('! World Hello')->then(F\split(' '))->then('array_reverse')->then(F\join(' '))->get());
 }
Esempio n. 3
0
function generateClass($name)
{
    $content = F\pipe(F\map('Demo\\block'), F\filter(function ($block) {
        return in_array($block->type, ['method', 'class']) && !$block->is_internal;
    }), f\map(function ($block) use($name) {
        if ($block->type == 'method') {
            $block->name = ($block->is_static ? $name . '::' : '') . $block->name;
        }
        return $block;
    }), F\map(function ($block) {
        return ['name' => $block->name, 'md' => markdown($block)];
    }), addContents($name), F\join("\n\n"));
    file_put_contents("docs/{$name}.md", $content(json_decode(shell_exec("dox -r < src/{$name}.php"))));
}
Esempio n. 4
0
 /**
  * Converts the given syntax to a string.
  *
  * @param  Tarsana\Syntax\Syntax $value the data to encode
  * @return string
  */
 protected function doDump($value)
 {
     $result = '';
     if ($value instanceof StringSyntax) {
         $result = F\regReplace('/[^a-zA-Z-_]+/', '', $value->description());
     } else {
         if ($value instanceof NumberSyntax) {
             $result = '#' . F\regReplace('/[^a-zA-Z-_]+/', '', $value->description());
         } else {
             if ($value instanceof BooleanSyntax) {
                 $result = F\regReplace('/[^a-zA-Z-_]+/', '', $value->description()) . '?';
             } else {
                 if ($value instanceof ArraySyntax) {
                     $item = $value->itemSyntax();
                     $oldDescription = $item->description();
                     $text = $this->dump($item->description($value->description()));
                     $item->description($oldDescription);
                     $result = "{$text}[{$value->separator()}]";
                 } else {
                     if ($value instanceof ObjectSyntax) {
                         $fields = [];
                         foreach ($value->fields() as $name => $item) {
                             $oldDescription = $item->description();
                             $item->description($name);
                             $fields[] = $this->dump($item);
                             $item->description($oldDescription);
                         }
                         $fields = F\join($this->fieldsSeparator, $fields);
                         $name = F\regReplace('/[^a-zA-Z-_]+/', '', $value->description());
                         $result = "{$name}{{$value->separator()}{$this->fieldsSeparator}{$fields}}";
                     }
                 }
             }
         }
     }
     if (!$value->isRequired()) {
         $result = "[{$result}]";
     }
     return $result;
 }