/** * 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; }
/** * */ public function testApiRead_ThrowsException_WhenModelReadThrowsException() { $path = 'path'; $ex = null; $this->expect('read', [$path])->willThrow($expected = new Exception()); try { $this->fs->read($path); } catch (Exception $ex) { } $this->assertInstanceOf(ReadException::class, $ex); $this->assertSame($expected, $ex->getPrevious()); }
/** * 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; }