Code Duplication    Length = 16-16 lines in 2 locations

src/EoC/CLI/Command/UseCommand.php 1 location

@@ 46-61 (lines=16) @@
43
  protected function execute(InputInterface $input, OutputInterface $output) {
44
    $database = (string)$input->getArgument('database');
45
46
    if ($shmKey = ftok($_SERVER['PHP_SELF'], 'd')) {
47
48
      if (@$shmId = shmop_open($shmKey, 'a', 0644, 0))
49
        shmop_delete($shmId);
50
51
      $shmId = shmop_open($shmKey, 'n', 0644, mb_strlen($database));
52
53
      if ($shmId) {
54
        $shmBytesWritten = shmop_write($shmId, $database, 0);
55
        shmop_close($shmId);
56
      }
57
      else
58
        throw new \RuntimeException("Couldn't create shared memory segment.");
59
    }
60
    else
61
      throw new \RuntimeException("Cannot get a System V IPC key.");
62
  }
63
64
}

src/EoC/CLI/Command/ConnectCommand.php 1 location

@@ 86-101 (lines=16) @@
83
        shmop_delete($shmId);
84
    }
85
86
    if ($shmKey = ftok($_SERVER['PHP_SELF'], 'c')) {
87
88
      if (@$shmId = shmop_open($shmKey, 'a', 0644, 0))
89
        shmop_delete($shmId);
90
91
      $shmId = shmop_open($shmKey, 'n', 0644, mb_strlen($serialized));
92
93
      if ($shmId) {
94
        $shmBytesWritten = shmop_write($shmId, $serialized, 0);
95
        shmop_close($shmId);
96
      }
97
      else
98
        throw new \RuntimeException("Couldn't create shared memory segment.");
99
    }
100
    else
101
      throw new \RuntimeException("Cannot get a System V IPC key.");
102
  }
103
104
}