web: Refactor avec une classe AbstractPackage

This commit is contained in:
2022-12-16 09:40:53 +01:00
parent 3ed6e6d802
commit f88b88cbf5
3 changed files with 33 additions and 48 deletions

View 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;
}
}

View File

@@ -4,16 +4,8 @@ declare(strict_types=1);
namespace Oki\Model; namespace Oki\Model;
use JsonSerializable; class Package extends AbstractPackage
class Package implements JsonSerializable
{ {
private int $id_package;
private string $short_name;
private string $description;
/** /**
* @var PackageVersion[] * @var PackageVersion[]
*/ */
@@ -24,21 +16,6 @@ class Package implements JsonSerializable
$this->versions = $versions; $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 public function getVersions(): array
{ {
return $this->versions; return $this->versions;

View File

@@ -4,16 +4,8 @@ declare(strict_types=1);
namespace Oki\Model; namespace Oki\Model;
use JsonSerializable; class PackageResume extends AbstractPackage
class PackageResume implements JsonSerializable
{ {
private int $id_package;
private string $short_name;
private string $description;
private ?string $latest_version; private ?string $latest_version;
public function setLatestVersion(string $latest_version) public function setLatestVersion(string $latest_version)
@@ -21,21 +13,6 @@ class PackageResume implements JsonSerializable
$this->latest_version = $latest_version; $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 public function getLatestVersion(): ?string
{ {
return $this->latest_version; return $this->latest_version;