/**
  * @param CommitMessage $commitMessage
  * @return ChangeInfoEnvelope
  */
 public function parse(CommitMessage $commitMessage)
 {
     $fullBody = $commitMessage->getBody();
     $splittedBodies = explode("\n\n", $fullBody);
     $lastBody = $splittedBodies[count($splittedBodies) - 1];
     $changeInfoList = [];
     $version = null;
     $environment = null;
     if (self::containsVersion($lastBody)) {
         $version = self::extractTag(ChangeInfoEnvelope::VP_VERSION_TAG, $lastBody);
         $environment = self::extractTag(ChangeInfoEnvelope::VP_ENVIRONMENT_TAG, $lastBody);
         array_pop($splittedBodies);
     }
     if (!self::isTrackedChangeInfo($fullBody)) {
         return new ChangeInfoEnvelope([new UntrackedChangeInfo($commitMessage)], $version, $environment);
     }
     foreach ($splittedBodies as $body) {
         $partialCommitMessage = new CommitMessage("", $body);
         $actionTag = $partialCommitMessage->getVersionPressTag(TrackedChangeInfo::ACTION_TAG);
         list($scope, $action, $id) = array_pad(explode('/', $actionTag, 3), 3, null);
         $tags = $partialCommitMessage->getVersionPressTags();
         unset($tags[TrackedChangeInfo::ACTION_TAG]);
         $actionsInfo = $this->actionsInfoProvider->getActionsInfo($scope);
         if ($this->dbSchema->isEntity($scope)) {
             $entityInfo = $this->dbSchema->getEntityInfo($scope);
             $changeInfoList[] = new EntityChangeInfo($entityInfo, $actionsInfo, $action, $id, $tags, []);
         } else {
             $changeInfoList[] = new TrackedChangeInfo($scope, $actionsInfo, $action, $id, $tags, []);
         }
     }
     return new ChangeInfoEnvelope($changeInfoList, $version, $environment);
 }
 /**
  * @test
  */
 public function actionsInfoTakesIteratorAsParameter()
 {
     $description = 'Some description';
     $scopeDefinition = ['some-scope' => ['actions' => ['some-action' => $description]]];
     $actionsFilePath = $this->createActionsFile($scopeDefinition);
     $actionsInfoProvider = new ActionsInfoProvider(new \ArrayIterator([$actionsFilePath]));
     $this->assertInstanceOf(ActionsInfo::class, $actionsInfoProvider->getActionsInfo('some-scope'));
 }
 public function createTrackedChangeInfo($scope, $action, $entityId = null, $tags = [], $files = [])
 {
     return new TrackedChangeInfo($scope, $this->actionsInfoProvider->getActionsInfo($scope), $action, $entityId, $tags, $files);
 }