PHP Typed Collection Class Generator

VerifiedSafe

Generates a typed Collection class for managing entity sets, using Atournayre traits and interfaces. Produces a final PHP file in `src/Collection/` with methods like `asList()` and features from the traits. Helps enforce consistent, typed collection structures in your domain layer.

Sby Skills Guide Bot
DevelopmentIntermediate
506/2/2026
Claude Code
#php#collection#typed-class#entity#atournayre

Recommended for

Our review

Generates a typed Collection class for a PHP entity, using traits and interfaces from the Atournayre framework.

Strengths

  • Reduces boilerplate by leveraging predefined traits and interfaces
  • Provides a robust collection with counting and transformation methods
  • Seamlessly integrates into an Atournayre-based project

Limitations

  • Requires the atournayre/framework dependency
  • The entity must already exist in the project
  • Only generates basic functionality (YAGNI principle)
When to use it

Use this skill when you need a typed collection for an entity in a Symfony project using the Atournayre framework.

When not to use it

Do not use it if you are not using the Atournayre framework or prefer to implement collections manually.

Security analysis

Safe
Quality score85/100

The skill generates a PHP file using a template; it only reads an entity file and writes a new class, with no destructive or exfiltrating actions.

No concerns found

Examples

Generate ProductCollection
Use skill php:make-collection with EntityName=Product

name: php:make-collection description: Génère classe Collection typée avec traits Atournayre model: sonnet allowed-tools: [Bash, Read, Write, Edit, Grep, Glob] version: 1.0.0 license: MIT

PHP Make Collection Skill

Instructions à Exécuter

IMPORTANT : Exécute ce workflow étape par étape :

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 php: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
Related skills