Пример #1
0
 /**
  * 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
 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");
 }