Files
Nexora/docs/ProjectNamingCodeGenerator.md
Javi 88e526cf6c
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
mejoras en la gestión de nombres y códigos de proyectos y documentos según la norma ISO 19650
2025-10-25 11:30:59 +02:00

80 lines
3.5 KiB
Markdown

# Project Naming Code Generator
## Overview
The `ProjectNamingSchema` class provides a utility to generate project names based on the ISO 19650 naming convention. This ensures consistency and compliance with industry standards.
## Installation
Ensure the `ProjectNamingSchema` class is located in the `App\Helpers` namespace. No additional installation steps are required.
## Usage
To generate a project name, use the `generate` method of the `ProjectNamingSchema` class. This method accepts an associative array of fields and returns the generated project name.
### Example
```php
use App\Helpers\ProjectNamingSchema;
$fields = [
'project' => 'PRJ001',
'creator' => 'ORG01',
'volume' => 'V01',
'level' => 'L01',
'documentType' => 'DOC',
'discipline' => 'ARC',
'number' => '1',
'description' => 'Description',
'status' => 'ST',
'revision' => '1',
];
$projectName = ProjectNamingSchema::generate($fields);
// Output: PRJ001-ORG01-V01-L01-DOC-ARC-001-Description-ST-0001
```
## Fields
The following fields are supported:
| Field | Definition | Requirement | Length |
|--------------------|---------------------------------------------------------------------------|-------------------|--------------|
| **project** | Identifies the project, contract, or file. | Required | 2-12 |
| **creator** | Organization responsible for creating the document. | Required | 3-6 |
| **volume** | Representative groupings, areas, or sections of the project. | Required | 2-3 |
| **level** | Location within a Volume or System. | Required | 3 |
| **documentType** | Document type, deliverable, or auxiliary. | Required | 3 |
| **discipline** | Scope to which the document corresponds. | Required | 3 |
| **number** | Part enumerator. | Required | 3 |
| **description** | Text describing the document and its content. | Optional | Unlimited |
| **status** | Temporary or definitive status of the document. | Optional | 2 |
| **revision** | Document version. | Optional | 4 |
## Validation
The `generate` method validates that all required fields are provided. If any required field is missing, an `InvalidArgumentException` is thrown.
### Example
```php
$fields = [
'creator' => 'ORG01',
'volume' => 'V01',
'level' => 'L01',
'documentType' => 'DOC',
'discipline' => 'ARC',
'number' => '1',
];
try {
$projectName = ProjectNamingSchema::generate($fields);
} catch (InvalidArgumentException $e) {
echo $e->getMessage(); // Output: The field 'project' is required.
}
```
## Testing
Unit tests for the `ProjectNamingSchema` class are located in the `tests/Unit/ProjectNamingSchemaTest.php` file. Run the tests using the following command:
```bash
vendor\bin\pest --filter ProjectNamingSchemaTest
```
## Notes
- All fields marked as "Required" must be included.
- Optional fields can be omitted if not applicable.