Пример #1
0
 public function testCapture()
 {
     $pattern = '#@param[ \\t]+?(\\w+)[ \\t]+?\\$(\\w+)[ \\t]+(.+)#';
     $regex = new Regex($pattern);
     $text = new Text("@param Text \$test This is a description\n" . "@param Uint \$asdf Something different");
     $capture = $regex->capture($text);
     $this->assertEquals([['Text', 'test', 'This is a description'], ['Uint', 'asdf', 'Something different']], $capture);
 }
Пример #2
0
 public function __construct($raw)
 {
     $regex = new Regex('/^([a-f0-9]{8})([a-f0-9]{6})([a-f0-9]{4})([a-f0-9]{6})$/');
     $matches = $regex->capture(new Text($raw));
     if (empty($matches)) {
         throw new InvalidArgumentException('Expected MongoDB ID, but got [' . var_export($raw, true) . '] instead');
     }
     list($this->time, $this->machine_id, $this->process_id, $this->counter) = $matches[0];
     $this->raw = $raw;
 }