web: Refactor avec une classe AbstractPackage
This commit is contained in:
31
web/src/Oki/Model/AbstractPackage.php
Normal file
31
web/src/Oki/Model/AbstractPackage.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Oki\Model;
|
||||
|
||||
use JsonSerializable;
|
||||
|
||||
abstract class AbstractPackage implements JsonSerializable
|
||||
{
|
||||
protected int $id_package;
|
||||
|
||||
protected string $short_name;
|
||||
|
||||
protected string $description;
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id_package;
|
||||
}
|
||||
|
||||
public function getShortName(): string
|
||||
{
|
||||
return $this->short_name;
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
}
|
@@ -4,16 +4,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Oki\Model;
|
||||
|
||||
use JsonSerializable;
|
||||
|
||||
class Package implements JsonSerializable
|
||||
class Package extends AbstractPackage
|
||||
{
|
||||
private int $id_package;
|
||||
|
||||
private string $short_name;
|
||||
|
||||
private string $description;
|
||||
|
||||
/**
|
||||
* @var PackageVersion[]
|
||||
*/
|
||||
@@ -24,21 +16,6 @@ class Package implements JsonSerializable
|
||||
$this->versions = $versions;
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id_package;
|
||||
}
|
||||
|
||||
public function getShortName(): string
|
||||
{
|
||||
return $this->short_name;
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function getVersions(): array
|
||||
{
|
||||
return $this->versions;
|
||||
|
@@ -4,16 +4,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Oki\Model;
|
||||
|
||||
use JsonSerializable;
|
||||
|
||||
class PackageResume implements JsonSerializable
|
||||
class PackageResume extends AbstractPackage
|
||||
{
|
||||
private int $id_package;
|
||||
|
||||
private string $short_name;
|
||||
|
||||
private string $description;
|
||||
|
||||
private ?string $latest_version;
|
||||
|
||||
public function setLatestVersion(string $latest_version)
|
||||
@@ -21,21 +13,6 @@ class PackageResume implements JsonSerializable
|
||||
$this->latest_version = $latest_version;
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id_package;
|
||||
}
|
||||
|
||||
public function getShortName(): string
|
||||
{
|
||||
return $this->short_name;
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function getLatestVersion(): ?string
|
||||
{
|
||||
return $this->latest_version;
|
||||
|
Reference in New Issue
Block a user