Code Duplication    Length = 14-14 lines in 2 locations

src/EoC/CLI/Command/AbstractCommand.php 2 locations

@@ 142-155 (lines=14) @@
139
  protected function getConnection() {
140
    $shmKey = ftok($_SERVER['PHP_SELF'], 'c');
141
142
    if (@$shmId = shmop_open($shmKey, "a", 0, 0)) {
143
      // Gets shared memory block's size.
144
      $shmSize = shmop_size($shmId);
145
146
      // Now lets read the memory segment.
147
      if ($buffer = shmop_read($shmId, 0, $shmSize))
148
        $connection = unserialize($buffer);
149
      else
150
        throw new \RuntimeException("You are not connected to the server.");
151
152
      shmop_close($shmId);
153
    }
154
    else
155
      throw new \RuntimeException("You are not connected to the server.");
156
157
    return new Couch(new CurlAdapter($connection['server'], $connection['user'], $connection['password']));
158
  }
@@ 168-181 (lines=14) @@
165
  protected function getDatabase() {
166
    $shmKey = ftok($_SERVER['PHP_SELF'], 'd');
167
168
    if (@$shmId = shmop_open($shmKey, "a", 0, 0)) {
169
      // Gets shared memory block's size.
170
      $shmSize = shmop_size($shmId);
171
172
      // Now lets read the memory segment.
173
      if ($buffer = shmop_read($shmId, 0, $shmSize))
174
        $database = $buffer;
175
      else
176
        throw new \RuntimeException("No database selected.");
177
178
      shmop_close($shmId);
179
    }
180
    else
181
      throw new \RuntimeException("No database selected.");
182
183
    return $database;
184
  }