<?php

declare(strict_types=1);

namespace Mapper;

use \Feast\BaseMapper;
use \Model\{name};

class {name}{classExtra} extends BaseMapper
{
    protected const OBJECT_NAME = {name}::class;
    protected const PRIMARY_KEY = '{primaryKey}';
    public const TABLE_NAME = '{table}';
{connection}
    /**
     * @param int|string $value
     * @param bool $validate
     * @return ?{name}
     */
    public function findByPrimaryKey(int|string $value, bool $validate = false): ?{name}
    {
        $record = parent::findByPrimaryKey($value, $validate);
        if ($record instanceof {name}) {
            return $record;
        }

        return null;
    }

    /**
     * This method is called when a Model is saved.
     *
     * Update this to call actions on save.
     *
     * @param {name} $record
     * @param bool $new
     */
    protected function onSave({name} $record, bool $new = true): void
    {
    }

    /**
     * This method is called when a Model is deleted.
     *
     * Update this to call actions on deletion.
     *
     * @param {name} $record
     */
    protected function onDelete({name} $record): void
    {
    }
}
