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

View File

@@ -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;