Generates a Shared Contract (Interface) and its implementation outline. Use when a module needs to expose data or behavior to other modules (e.g., "Create a contract for getting student GPA").
This skill generates a Shared Contract (Interface) and guides the implementation, enforcing the project's strict boundary rules.
Analyze Request:
Academic, Finance).{Noun}{Verb}{Purpose} (e.g., StudentAcademicReader, WalletBalanceProvider).Verify Rules:
Generate Files:
app/Shared/Contracts/{Domain}/{Name}.phpapp/Modules/{Domain}/Services/{Name}Implementation.php (Suggest this path).Register:
{Domain}ServiceProvider.<?php
namespace App\Shared\Contracts\Academic;
use App\Shared\DTO\StudentGpaDTO; // Example DTO
interface StudentAcademicReader
{
/**
* Get the GPA for a specific student.
*
* @param int $studentId
* @return float
*/
public function getStudentGpa(int $studentId): float;
/**
* Get detailed academic summary.
*
* @param int $studentId
* @return StudentGpaDTO
*/
public function getStudentSummary(int $studentId): StudentGpaDTO;
}
// In app/Modules/Academic/Services/StudentAcademicReaderImplementation.php
namespace App\Modules\Academic\Services;
use App\Shared\Contracts\Academic\StudentAcademicReader;
use App\Modules\Academic\Models\AcademicRecord;
use App\Shared\DTO\StudentGpaDTO;
class StudentAcademicReaderImplementation implements StudentAcademicReader
{
public function getStudentGpa(int $studentId): float
{
// Implementation logic here
return AcademicRecord::where('student_id', $studentId)->avg('gpa') ?? 0.0;
}
// ...
}
// In app/Modules/Academic/Providers/AcademicServiceProvider.php
public function register(): void
{
$this->app->bind(
\App\Shared\Contracts\Academic\StudentAcademicReader::class,
\App\Modules\Academic\Services\StudentAcademicReaderImplementation::class
);
}
app/Shared/Contracts?