refactor: add rector to enforce type declarations, code quality + style and remove dead code

- update CI process to include quality stage (tests + code review)
- add captainhook to install git pre-commit & pre-push hooks
- remove .devcontainer Dockerfile to use project's docker-compose services: all
services can now be started automatically using vscode
- update docs/setup-development.md
This commit is contained in:
Yassine Doghri 2021-05-06 14:00:48 +00:00
commit 5c5c6da4be
No known key found for this signature in database
GPG key ID: 3E7F89498B960C9F
302 changed files with 9802 additions and 4674 deletions

View file

@ -11,13 +11,24 @@
namespace App\Models;
use CodeIgniter\Database\BaseResult;
use App\Entities\Soundbite;
use CodeIgniter\Model;
class SoundbiteModel extends Model
{
/**
* @var string
*/
protected $table = 'soundbites';
/**
* @var string
*/
protected $primaryKey = 'id';
/**
* @var string[]
*/
protected $allowedFields = [
'podcast_id',
'episode_id',
@ -28,15 +39,36 @@ class SoundbiteModel extends Model
'updated_by',
];
protected $returnType = \App\Entities\Soundbite::class;
/**
* @var string
*/
protected $returnType = Soundbite::class;
/**
* @var bool
*/
protected $useSoftDeletes = false;
/**
* @var bool
*/
protected $useTimestamps = true;
/**
* @var string[]
*/
protected $afterInsert = ['clearCache'];
/**
* @var string[]
*/
protected $afterUpdate = ['clearCache'];
/**
* @var string[]
*/
protected $beforeDelete = ['clearCache'];
/**
* @return bool|BaseResult
*/
public function deleteSoundbite($podcastId, $episodeId, $soundbiteId)
{
return $this->delete([
@ -49,10 +81,7 @@ class SoundbiteModel extends Model
/**
* Gets all soundbites for an episode
*
* @param int $podcastId
* @param int $episodeId
*
* @return \App\Entities\Soundbite[]
* @return Soundbite[]
*/
public function getEpisodeSoundbites(int $podcastId, int $episodeId): array
{
@ -69,7 +98,10 @@ class SoundbiteModel extends Model
return $found;
}
public function clearCache(array $data)
/**
* @return array<string, array<string|int, mixed>>
*/
public function clearCache(array $data): array
{
$episode = (new EpisodeModel())->find(
isset($data['data'])