frameworkmakecollection

Génère classe Collection typée avec traits Atournayre

⭐6stars🔀0forks📁View on GitHub🕐Updated Jan 2, 2026⬇️1downloads

When & Why to Use This Skill

This Claude skill automates the generation of strongly-typed PHP Collection classes specifically tailored for the Atournayre framework. It streamlines the development workflow by automatically implementing essential traits and interfaces—such as CountInterface and ToArrayInterface—ensuring that entity collections are consistent, type-safe, and follow project architectural standards without manual boilerplate coding.

Use Cases

  • Rapid Scaffolding: Quickly generate a dedicated Collection class (e.g., ProductCollection) immediately after creating a new entity to handle sets of data efficiently.
  • Standardizing Project Architecture: Ensure all developers on a team use the same 'final' class patterns and Atournayre traits, maintaining a clean and predictable codebase.
  • Enhancing Type Safety: Create typed collections that enforce strict entity handling, reducing bugs related to passing incorrect object types in PHP applications.
  • Legacy Code Modernization: Easily wrap existing entity arrays into structured Collection classes to take advantage of built-in methods like asList() and countBy().
nameframework:make:collection
descriptionGénère classe Collection typée avec traits Atournayre
licenseMIT
version1.0.0

Framework Make Collection Skill

Description

Génère une classe Collection typée pour gérer des ensembles d'entités avec les traits et interfaces Atournayre.

Usage

Use skill framework:make:collection

Variables requises

  • {EntityName} - Nom de l'entité en PascalCase (ex: Product)
  • {entityName} - Nom de l'entité en camelCase (ex: product)
  • {namespace} - Namespace du projet (défaut: App)

Dépendances

  • Entité dans src/Entity/{EntityName}.php
  • Framework atournayre/framework

Outputs

  • src/Collection/{EntityName}Collection.php

Workflow

  1. Demander le nom de l'entité (EntityName)
  2. Vérifier que l'entité existe dans src/Entity/{EntityName}.php
    • Si non : arrêter et demander de créer l'entité d'abord
  3. Générer la classe Collection depuis le template templates/Collection/
  4. Afficher le fichier créé

Patterns appliqués

  • Classe final
  • Interfaces : AsListInterface, ToArrayInterface, CountInterface, CountByInterface, AtLeastOneElementInterface, HasSeveralElementsInterface, HasNoElementInterface, HasOneElementInterface, HasXElementsInterface, LoggableInterface
  • Traits : Collection, Collection\ToArray, Collection\Countable
  • Méthode statique asList(array $collection)

References

  • Usage - Exemples d'utilisation et méthodes métier

Notes

  • Respect du principe YAGNI : pas de méthodes génériques anticipées
  • Seules les méthodes explicitement demandées doivent être ajoutées
  • Les traits fournissent déjà les fonctionnalités de base