Add comments

This commit is contained in:
Dennis Eichhorn 2016-10-24 20:47:29 +02:00
parent 95a38e5e6d
commit 3631e4918f
5 changed files with 88 additions and 18 deletions

View File

@ -32,8 +32,6 @@ use phpOMS\Pattern\Mediator;
*/ */
class EventManager implements Mediator class EventManager implements Mediator
{ {
const DELIM = ':';
/** /**
* Events. * Events.
* *

View File

@ -261,6 +261,9 @@ class Http implements UriInterface
return $this->path ?? ''; return $this->path ?? '';
} }
/**
* {@inheritdoc}
*/
public function getRoute() : string public function getRoute() : string
{ {
return ($this->path ?? '') . '?' . $this->getQuery(); return ($this->path ?? '') . '?' . $this->getQuery();

View File

@ -87,6 +87,18 @@ class UriFactory
return false; return false;
} }
/**
* Simplify url
*
* While adding, and removing elements to a uri it can have multiple parameters or empty parameters which need to be cleaned up
*
* @param string $url Url to simplify
*
* @return string
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
private static function unique(string $url) : string private static function unique(string $url) : string
{ {
$parts = explode('?', $url); $parts = explode('?', $url);

View File

@ -155,6 +155,16 @@ interface UriInterface
*/ */
public function getBase() : string; public function getBase() : string;
/**
* Get route representation of uri.
*
* @return string
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function getRoute() : string;
/** /**
* Set uri. * Set uri.
* *

View File

@ -301,15 +301,28 @@ class Repository
return implode("\n", $this->run('add ' . $files . ' -v')); return implode("\n", $this->run('add ' . $files . ' -v'));
} }
/**
* Remove file(s) from repository
*
* @param string|array $files Files to remove
* @param bool $cached ?
*
* @return string
*
* @throws \InvalidArgumentException
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function rm($files = '*', bool $cached = false) : string public function rm($files = '*', bool $cached = false) : string
{ {
if (is_array($files)) { if (is_array($files)) {
$files = '"' . implode('" "', $files) . '"'; $files = '"' . implode('" "', $files) . '"';
} elseif (!is_string($files)) { } elseif (!is_string($files)) {
throw new \Exception('Wrong type'); throw new \InvalidArgumentException('Wrong type for $files.');
} }
return $this->run('rm ' . ($cached ? '--cached ' : '') . $files); return implode("\n", $this->run('rm ' . ($cached ? '--cached ' : '') . $files));
} }
/** /**
@ -328,31 +341,65 @@ class Repository
return implode("\n", $this->run('commit ' . ($all ? '-av' : '-v') . ' -m ' . escapeshellarg($commit->getMessage()))); return implode("\n", $this->run('commit ' . ($all ? '-av' : '-v') . ' -m ' . escapeshellarg($commit->getMessage())));
} }
/**
* Clone repository to different directory
*
* @param string $target Target clone directory
*
* @return string
*
* @throws PathException in case the target is not a valid directory
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function cloneTo(string $target) : string public function cloneTo(string $target) : string
{ {
if (!is_dir($target)) { if (!is_dir($target)) {
throw new \Exception('Not a directory'); throw new PathException($target);
} }
return $this->run('clone --local ' . $this->path . ' ' . $target); return implode("\n", $this->run('clone --local ' . $this->path . ' ' . $target));
} }
/**
* Clone repository to current directory
*
* @param string $source Source repository to clone
*
* @return string
*
* @throws PathException in case the source repository is not valid
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function cloneFrom(string $source) : string public function cloneFrom(string $source) : string
{ {
if (!is_dir($source)) { if (!is_dir($source)) {
throw new \Exception('Not a directory'); throw new PathException($source);
} }
// todo: is valid git repository? // todo: is valid git repository?
return $this->run('clone --local ' . $source . ' ' . $this->path); return implode("\n", $this->run('clone --local ' . $source . ' ' . $this->path));
} }
/**
* Clone remote repository to current directory
*
* @param string $source Source repository to clone
*
* @return string
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function cloneRemote(string $source) : string public function cloneRemote(string $source) : string
{ {
// todo: is valid remote git repository? // todo: is valid remote git repository?
return $this->run('clone ' . $source . ' ' . $this->path); return implode("\n", $this->run('clone ' . $source . ' ' . $this->path));
} }
/** /**