90% of 188OPs |
97% of 33Lines |
75% of 28Branches |
68% of 19Paths |
| # | |
|---|---|
| 1 |
<?php |
| 2 |
|
| 3 |
namespace mageekguy\atoum\scripts\builder; |
| 4 |
|
| 5 |
use |
| 6 |
mageekguy\atoum, |
| 7 |
mageekguy\atoum\exceptions |
| 8 |
; |
| 9 |
|
| 10 |
abstract class vcs |
| 11 |
{
|
| 12 |
protected $adapter = null; |
| 13 |
protected $repositoryUrl = null; |
| 14 |
protected $revision = null; |
| 15 |
protected $username = null; |
| 16 |
protected $password = null; |
| 17 |
protected $workingDirectory = null; |
| 18 |
|
| 19 |
public function __construct(atoum\adapter $adapter = null) |
| 20 |
{
|
| 21 |
$this->setAdapter($adapter ?: new atoum\adapter()); |
| 22 |
} |
| 23 |
|
| 24 |
public function setAdapter(atoum\adapter $adapter)100% |
| 25 |
{
|
| 26 |
$this->adapter = $adapter; |
| 27 |
|
| 28 |
return $this; |
| 29 |
} |
| 30 |
|
| 31 |
public function getAdapter()100% |
| 32 |
{
|
| 33 |
return $this->adapter; |
| 34 |
} |
| 35 |
|
| 36 |
public function setWorkingDirectory($workingDirectory)100% |
| 37 |
{
|
| 38 |
$this->workingDirectory = (string) $workingDirectory; |
| 39 |
|
| 40 |
return $this; |
| 41 |
} |
| 42 |
|
| 43 |
public function getWorkingDirectory()100% |
| 44 |
{
|
| 45 |
return $this->workingDirectory; |
| 46 |
} |
| 47 |
|
| 48 |
public function getWorkingDirectoryIterator()75% |
| 49 |
{
|
| 50 |
if ($this->workingDirectory === null) |
| 51 |
{
|
| 52 |
throw new exceptions\runtime('Unable to clean working directory because it is undefined');
|
| 53 |
} |
| 54 |
|
| 55 |
return new \recursiveIteratorIterator(new \recursiveDirectoryIterator($this->workingDirectory, \filesystemIterator::KEY_AS_PATHNAME | \filesystemIterator::CURRENT_AS_FILEINFO | \filesystemIterator::SKIP_DOTS), \recursiveIteratorIterator::CHILD_FIRST); |
| 56 |
} |
| 57 |
|
| 58 |
public function setRepositoryUrl($url)100% |
| 59 |
{
|
| 60 |
$this->repositoryUrl = (string) $url; |
| 61 |
|
| 62 |
return $this; |
| 63 |
} |
| 64 |
|
| 65 |
public function getRepositoryUrl()100% |
| 66 |
{
|
| 67 |
return $this->repositoryUrl; |
| 68 |
} |
| 69 |
|
| 70 |
public function setRevision($revisionNumber)100% |
| 71 |
{
|
| 72 |
$this->revision = (int) $revisionNumber; |
| 73 |
|
| 74 |
return $this; |
| 75 |
} |
| 76 |
|
| 77 |
public function getRevision()100% |
| 78 |
{
|
| 79 |
return $this->revision; |
| 80 |
} |
| 81 |
|
| 82 |
public function setUsername($username)100% |
| 83 |
{
|
| 84 |
$this->username = (string) $username; |
| 85 |
|
| 86 |
return $this; |
| 87 |
} |
| 88 |
|
| 89 |
public function getUsername()100% |
| 90 |
{
|
| 91 |
return $this->username; |
| 92 |
} |
| 93 |
|
| 94 |
public function setPassword($password)100% |
| 95 |
{
|
| 96 |
$this->password = (string) $password; |
| 97 |
|
| 98 |
return $this; |
| 99 |
} |
| 100 |
|
| 101 |
public function getPassword()100% |
| 102 |
{
|
| 103 |
return $this->password; |
| 104 |
} |
| 105 |
|
| 106 |
public abstract function getNextRevisions(); |
| 107 |
|
| 108 |
public abstract function exportRepository(); |
| 109 |
|
| 110 |
public function cleanWorkingDirectory()100% |
| 111 |
{
|
| 112 |
foreach ($this->getWorkingDirectoryIterator() as $inode) |
| 113 |
{
|
| 114 |
if ($inode->isDir() === false) |
| 115 |
{
|
| 116 |
$this->adapter->unlink($inode->getPathname()); |
| 117 |
} |
| 118 |
else if (($pathname = $inode->getPathname()) !== $this->workingDirectory) |
| 119 |
{
|
| 120 |
$this->adapter->rmdir($pathname); |
| 121 |
} |
| 122 |
} |
| 123 |
|
| 124 |
return $this; |
| 125 |
} |
| 126 |
} |