mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-27 08:28:40 +00:00
Restructure for better oop support
This commit is contained in:
parent
78e0d51c92
commit
c5c21f4807
25
Utils/Git/Author.php
Normal file
25
Utils/Git/Author.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace phpOMS\Utils\Git;
|
||||
|
||||
class Author
|
||||
{
|
||||
private $name = '';
|
||||
private $email = '';
|
||||
|
||||
public function __construct(string $name, string $email)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->email = $email;
|
||||
}
|
||||
|
||||
public function getName() : string
|
||||
{
|
||||
return $name;
|
||||
}
|
||||
|
||||
public function getEmail() : string
|
||||
{
|
||||
return $email;
|
||||
}
|
||||
}
|
||||
23
Utils/Git/Branch
Normal file
23
Utils/Git/Branch
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace phpOMS\Utils\Git;
|
||||
|
||||
class Branch
|
||||
{
|
||||
private $name = '';
|
||||
|
||||
public function __construct(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function setName(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function getName() : string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
|
||||
namespace phpOMS\Utils\Git;
|
||||
|
||||
class Commit
|
||||
{
|
||||
private $id = '';
|
||||
private $author = null;
|
||||
private $branch = null;
|
||||
private $tag = null;
|
||||
private $date = null;
|
||||
private $repository = null;
|
||||
private $message = '';
|
||||
private $files = [];
|
||||
|
||||
public function __construct(string $id = '') {
|
||||
$author = new Author();
|
||||
$branch = new Branch();
|
||||
$tag = new Tag();
|
||||
|
||||
if(!empty($id)) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function addFile(string $path) {
|
||||
if(!isset($this->files[$path])) {
|
||||
$this->files[$path] = [];
|
||||
}
|
||||
}
|
||||
|
||||
public function addChange(string $path, int $line, string $old, string $new)
|
||||
{
|
||||
if(!isset($this->files[$path])) {
|
||||
throw new \Exception();
|
||||
}
|
||||
|
||||
if(!isset($this->files[$path][$line])) {
|
||||
$this->files[$path][$line] => ['old' => $old, 'new' => $new];
|
||||
} else {
|
||||
throw new \Exception();
|
||||
}
|
||||
}
|
||||
|
||||
public function setMessage(string $message)
|
||||
{
|
||||
$this->message = $message;
|
||||
}
|
||||
|
||||
public function getMessage() : string
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
public function getFiles() : array {
|
||||
return $this->files;
|
||||
}
|
||||
|
||||
public function removeFile(string $path) {
|
||||
|
||||
}
|
||||
|
||||
public function setAuthor(Author $author)
|
||||
{
|
||||
$this->author = $author;
|
||||
}
|
||||
|
||||
public function getAuthor() : Author
|
||||
{
|
||||
return $this->author;
|
||||
}
|
||||
|
||||
public function setBranch(Branch $branch) {
|
||||
$this->branch = $branch;
|
||||
}
|
||||
|
||||
public function getBranch() : Branch
|
||||
{
|
||||
return $this->branch;
|
||||
}
|
||||
|
||||
public function setTag(Tag $tag) {
|
||||
$this->tag = $tag;
|
||||
}
|
||||
|
||||
public function getTag() : Tag
|
||||
{
|
||||
return $this->tag;
|
||||
}
|
||||
|
||||
public function getDate() : \DateTime
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
public function setRepository(Reporsitory $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
public function getRepository() : Reporsitory
|
||||
{
|
||||
retrun $this->repository;
|
||||
}
|
||||
}
|
||||
|
|
@ -266,7 +266,14 @@ class Repository
|
|||
|
||||
public function getCommitsCount() : string
|
||||
{
|
||||
return $this->run('shortlog -s -n --all');
|
||||
$result = $this->normalizeResult($this->run('shortlog -s -n --all'));
|
||||
|
||||
return [''];
|
||||
}
|
||||
|
||||
private function normalizeResult(string $result) : string
|
||||
{
|
||||
str_replace('\t', '|', trim($result));
|
||||
}
|
||||
|
||||
public function getCommitsBy(string $author, \DateTime $start, \DateTime $end) : string
|
||||
|
|
|
|||
0
Utils/Git/Tag.php
Normal file
0
Utils/Git/Tag.php
Normal file
Loading…
Reference in New Issue
Block a user