示例#1
0
文件: DotArray.php 项目: nochso/omni
 /**
  * Flatten the array into a single dimension array with escaped dot paths as keys.
  *
  * Dots within specific keys are escaped.
  *
  * @return array
  */
 public function flatten()
 {
     return Dot::flatten($this->data);
 }
示例#2
0
 /**
  * @return null|string
  */
 private function readMercurial()
 {
     $hgDir = Path::combine($this->repositoryRoot, '.hg');
     if (!is_dir($hgDir) || !OS::hasBinary('hg')) {
         return null;
     }
     $hg = Exec::create('hg', '--repository', $this->repositoryRoot);
     // Removes everything but the tag if distance is zero.
     $hg->run('log', '-r', '.', '--template', '{latesttag}{sub(\'^-0-m.*\', \'\', \'-{latesttagdistance}-m{node|short}\')}');
     $tag = Dot::get($hg->getOutput(), 0);
     // Actual null if no lines were returned or `hg log` returned actual "null".
     // Either way, need to fall back to the revision id.
     if ($tag === null || $tag === 'null' || Strings::startsWith($tag, 'null-')) {
         $hg->run('id', '-i');
         $tag = Dot::get($hg->getOutput(), 0);
         // Remove 'dirty' plus from revision id
         $tag = rtrim($tag, '+');
     }
     $summary = $hg->run('summary')->getOutput();
     $isDirty = 0 === count(array_filter($summary, function ($line) {
         return preg_match('/^commit: .*\\(clean\\)$/', $line) === 1;
     }));
     if ($isDirty) {
         $tag .= '-dirty';
     }
     return $tag;
 }
示例#3
0
 /**
  * Создание массива точек по формуле Y
  */
 public function makeDots()
 {
     $start = $this->from_to[0];
     $finish = $this->from_to[1];
     $loops = $finish - $start;
     $i = 0;
     while ($i <= $loops * $this->res) {
         $x = $start + $i++ / $this->res;
         $ys = $this->calculateY($x);
         if ($ys != FALSE) {
             foreach ($ys as $y) {
                 $dot = new Dot();
                 $dot->setX($x);
                 $dot->setY($y);
                 $dot->setColor($this->color);
                 $this->dots[] = $dot;
             }
         }
     }
 }
示例#4
0
文件: DotTest.php 项目: mduk/dot
 public function testFlatten()
 {
     $dot = new Dot(['foo' => ['bar' => ['baz' => 'baz'], 'qha' => ['waz' => 'nih']]]);
     $this->assertEquals(['foo.bar.baz' => 'baz', 'foo.qha.waz' => 'nih'], $dot->flatten(), "Flatten should work");
 }