/**
  * @param array $processes
  *
  * @return ProcessCollection
  *
  * @throws \Tonic\ParallelProcessRunner\Exception\NotProcessException
  * @throws \Tonic\ParallelProcessRunner\Exception\ProcessAlreadyInCollectionException
  */
 private function getCollection(array $processes)
 {
     $collection = new ProcessCollection();
     foreach ($processes as $process) {
         $collection->add($process);
     }
     return $collection;
 }
 /**
  * {@inheritdoc}
  *
  * @param Process|Process[]|ProcessCollection|array $process
  *
  * @return array|int
  *
  * @throws ProcessesMustBeInReadyStatusException
  */
 public function add($process)
 {
     switch (true) {
         case is_array($process):
             $result = array_map(function ($process) {
                 return $this->add($process);
             }, $process);
             break;
         case $process instanceof ProcessCollection:
             $result = $this->add($process->toArray());
             break;
         case $process instanceof Process:
             if ($process->getStatus() != Process::STATUS_READY) {
                 throw new ProcessesMustBeInReadyStatusException($process);
             }
             // no break
         // no break
         default:
             $result = parent::add($process);
     }
     return $result;
 }
 /**
  * @param array|Process|null     $processes
  * @param ProcessCollection|null $collection
  *
  * @return ProcessCollection
  *
  * @throws NotProcessException
  */
 private function getCollection($processes = null, ProcessCollection $collection = null)
 {
     if (is_null($collection)) {
         $collection = new ProcessCollection();
     }
     if (!is_array($processes)) {
         $processes = [$processes];
     }
     foreach (array_filter($processes) as $process) {
         $collection->add($process);
     }
     return $collection;
 }
 /**
  * @return bool
  */
 protected function isRunning()
 {
     return !$this->activeCollection->isEmpty();
 }