示例#1
0
 /**
  * Retrieve file object by relative file path
  *
  * @param string $filePath Relative file path
  *
  * @return File
  */
 public function getFileByPath($filePath)
 {
     $normalizePath = ltrim($filePath, DIRECTORY_SEPARATOR);
     foreach ($this->getChangedFilesInternal() as $filePath => $status) {
         if ($normalizePath == $filePath) {
             return new File($this->repository->getProjectPath() . DIRECTORY_SEPARATOR . $filePath, $this->repository, $status);
         }
     }
     return null;
 }
示例#2
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     if (!$this->project instanceof Project) {
         throw new InvalidParamException('Project variable must be an instance of ' . Project::className());
     }
     if (!$this->repository instanceof BaseRepository) {
         throw new InvalidParamException('Repository variable must be an instance of ' . BaseRepository::className());
     }
     if (!$this->commit instanceof BaseCommit) {
         throw new InvalidParamException('Commit variable must be an instance of ' . BaseCommit::className());
     }
     if (!$this->file instanceof File) {
         throw new InvalidParamException('File variable must be an instance of ' . File::className());
     }
     $this->id = $this->commit->getId() . md5($this->file->getPathname());
 }
示例#3
0
 /**
  * Return path name without repository path
  *
  * @return string
  */
 public function getPathname()
 {
     return ltrim(mb_substr($this->path, mb_strlen($this->repository->getProjectPath())), DIRECTORY_SEPARATOR);
 }