Code Duplication    Length = 14-14 lines in 2 locations

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

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