コード例 #1
0
 /**
  * Copy data from persistent storage to temporary one.
  *
  * @return mixed
  * @throws ReadException
  */
 private function selectFromStorage()
 {
     if (!$this->fs->exists($this->fsPath)) {
         return $this->getEmptyStorage();
     }
     $data = json_decode($this->fs->read($this->fsPath), true);
     if (!isset($data['pid']) || !$this->system->existsPid($data['pid'])) {
         return $this->getEmptyStorage();
     }
     return $data;
 }
コード例 #2
0
 /**
  *
  */
 public function testApiGetTimestamp_ThrowsException_WhenGetMetadataOnModelThrowsException()
 {
     $path = 'path';
     $expected = new Exception();
     $ex = null;
     $this->expect('getTimestamp', [$path])->willThrow($expected);
     try {
         $this->fs->getTimestamp($path);
     } catch (Exception $ex) {
     }
     $this->assertInstanceOf(ReadException::class, $ex);
     $this->assertSame($expected, $ex->getPrevious());
 }
コード例 #3
0
 /**
  * Copy data from persistent storage to temporary one.
  *
  * @return string[][]
  * @throws ReadException
  */
 private function selectFromStorage()
 {
     if (!$this->fs->exists($this->fsPath)) {
         return [];
     }
     $processes = [];
     $data = json_decode($this->fs->read($this->fsPath), true);
     foreach ($data as $alias => $record) {
         if ($this->system->existsPid($record['pid'])) {
             $processes[$alias] = ['pid' => $record['pid'], 'name' => $record['name'], 'verified' => false];
         }
     }
     return $processes;
 }