phpstan, phpcs, phpunit fixes

This commit is contained in:
Dennis Eichhorn 2023-01-27 22:12:09 +01:00
parent 7d4c9acf17
commit 064fef7d82
8 changed files with 49 additions and 54 deletions

View File

@ -178,16 +178,16 @@ class Employee implements \JsonSerializable
/**
* Get media file by type
*
* @param null|int $type Media type
* @param int $type Media type
*
* @return Media
*
* @since 1.0.0
*/
public function getFileByType(int $type = null) : Media
public function getFileByType(int $type) : Media
{
foreach ($this->files as $file) {
if ($file->type === $type) {
if ($file->hasMediaTypeId($type)) {
return $file;
}
}
@ -196,26 +196,24 @@ class Employee implements \JsonSerializable
}
/**
* Get all media files by type
* Get all media files by type name
*
* @param null|int $type Media type
* @param string $type Media type
*
* @return Media[]
* @return Media
*
* @since 1.0.0
*/
public function getFilesByType(int $type = null) : array
public function getFileByTypeName(string $type) : Media
{
$files = [];
foreach ($this->files as $file) {
if ($file->type === $type) {
$files[] = $file;
if ($file->hasMediaTypeName($type)) {
return $file;
}
}
return $files;
return new NullMedia();
}
/**
* Get employee company history.
*

View File

@ -117,16 +117,16 @@ class EmployeeEducationHistory implements \JsonSerializable
/**
* Get media file by type
*
* @param null|int $type Media type
* @param int $type Media type
*
* @return Media
*
* @since 1.0.0
*/
public function getFileByType(int $type = null) : Media
public function getFileByType(int $type) : Media
{
foreach ($this->files as $file) {
if ($file->type === $type) {
if ($file->hasMediaTypeId($type)) {
return $file;
}
}
@ -135,24 +135,23 @@ class EmployeeEducationHistory implements \JsonSerializable
}
/**
* Get all media files by type
* Get all media files by type name
*
* @param null|int $type Media type
* @param string $type Media type
*
* @return Media[]
* @return Media
*
* @since 1.0.0
*/
public function getFilesByType(int $type = null) : array
public function getFileByTypeName(string $type) : Media
{
$files = [];
foreach ($this->files as $file) {
if ($file->type === $type) {
$files[] = $file;
if ($file->hasMediaTypeName($type)) {
return $file;
}
}
return $files;
return new NullMedia();
}
/**

View File

@ -47,7 +47,7 @@ final class EmployeeEducationHistoryMapper extends DataMapperFactory
/**
* Belongs to.
*
* @var array<string, array{mapper:string, external:string, column?:string, by?:string}>
* @var array<string, array{mapper:class-string, external:string, column?:string, by?:string}>
* @since 1.0.0
*/
public const BELONGS_TO = [
@ -60,7 +60,7 @@ final class EmployeeEducationHistoryMapper extends DataMapperFactory
/**
* Has many relation.
*
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
* @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
* @since 1.0.0
*/
public const HAS_MANY = [

View File

@ -140,16 +140,16 @@ class EmployeeHistory implements \JsonSerializable
/**
* Get media file by type
*
* @param null|int $type Media type
* @param int $type Media type
*
* @return Media
*
* @since 1.0.0
*/
public function getFileByType(int $type = null) : Media
public function getFileByType(int $type) : Media
{
foreach ($this->files as $file) {
if ($file->type === $type) {
if ($file->hasMediaTypeId($type)) {
return $file;
}
}
@ -158,24 +158,23 @@ class EmployeeHistory implements \JsonSerializable
}
/**
* Get all media files by type
* Get all media files by type name
*
* @param null|int $type Media type
* @param string $type Media type
*
* @return Media[]
* @return Media
*
* @since 1.0.0
*/
public function getFilesByType(int $type = null) : array
public function getFileByTypeName(string $type) : Media
{
$files = [];
foreach ($this->files as $file) {
if ($file->type === $type) {
$files[] = $file;
if ($file->hasMediaTypeName($type)) {
return $file;
}
}
return $files;
return new NullMedia();
}
/**

View File

@ -49,7 +49,7 @@ final class EmployeeHistoryMapper extends DataMapperFactory
/**
* Belongs to.
*
* @var array<string, array{mapper:string, external:string, column?:string, by?:string}>
* @var array<string, array{mapper:class-string, external:string, column?:string, by?:string}>
* @since 1.0.0
*/
public const BELONGS_TO = [
@ -74,7 +74,7 @@ final class EmployeeHistoryMapper extends DataMapperFactory
/**
* Has many relation.
*
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
* @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
* @since 1.0.0
*/
public const HAS_MANY = [

View File

@ -44,7 +44,7 @@ final class EmployeeMapper extends DataMapperFactory
/**
* Belongs to.
*
* @var array<string, array{mapper:string, external:string, column?:string, by?:string}>
* @var array<string, array{mapper:class-string, external:string, column?:string, by?:string}>
* @since 1.0.0
*/
public const BELONGS_TO = [
@ -57,7 +57,7 @@ final class EmployeeMapper extends DataMapperFactory
/**
* Has one relation.
*
* @var array<string, array{mapper:string, external:string, by?:string, column?:string, conditional?:bool}>
* @var array<string, array{mapper:class-string, external:string, by?:string, column?:string, conditional?:bool}>
* @since 1.0.0
*/
public const OWNS_ONE = [
@ -70,7 +70,7 @@ final class EmployeeMapper extends DataMapperFactory
/**
* Has many relation.
*
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
* @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
* @since 1.0.0
*/
public const HAS_MANY = [

View File

@ -113,16 +113,16 @@ class EmployeeWorkHistory implements \JsonSerializable
/**
* Get media file by type
*
* @param null|int $type Media type
* @param int $type Media type
*
* @return Media
*
* @since 1.0.0
*/
public function getFileByType(int $type = null) : Media
public function getFileByType(int $type) : Media
{
foreach ($this->files as $file) {
if ($file->type === $type) {
if ($file->hasMediaTypeId($type)) {
return $file;
}
}
@ -131,24 +131,23 @@ class EmployeeWorkHistory implements \JsonSerializable
}
/**
* Get all media files by type
* Get all media files by type name
*
* @param null|int $type Media type
* @param string $type Media type
*
* @return Media[]
* @return Media
*
* @since 1.0.0
*/
public function getFilesByType(int $type = null) : array
public function getFileByTypeName(string $type) : Media
{
$files = [];
foreach ($this->files as $file) {
if ($file->type === $type) {
$files[] = $file;
if ($file->hasMediaTypeName($type)) {
return $file;
}
}
return $files;
return new NullMedia();
}
/**

View File

@ -45,7 +45,7 @@ final class EmployeeWorkHistoryMapper extends DataMapperFactory
/**
* Belongs to.
*
* @var array<string, array{mapper:string, external:string, column?:string, by?:string}>
* @var array<string, array{mapper:class-string, external:string, column?:string, by?:string}>
* @since 1.0.0
*/
public const BELONGS_TO = [
@ -58,7 +58,7 @@ final class EmployeeWorkHistoryMapper extends DataMapperFactory
/**
* Has many relation.
*
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
* @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
* @since 1.0.0
*/
public const HAS_MANY = [