# carlosas/phpat architecture

> Architecture diagram of the GitHub repository carlosas/phpat, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/carlosas/phpat
- Repository: https://github.com/carlosas/phpat

## Overview

##### Main Components

a) Core Components:
- Test Runner System
- Rule Engine
- Parser System
- Assertion System
- Selector System

b) Supporting Components:
- Configuration Handler
- Statement Builder
- Test Builder
- Extractor System

##### Component Relationships and Structure

**┌─────────────────────────────────────────────────────────┐**
- Test Runner (PHPat)                 │
- ┬─────────────────────────┘

**┌───────────────────────────────▼─────────────────────────┐**
- Rule Engine & Validator              │
- ┬─────────────┬────────────────────┬────┤
- Declaration    │  Relation   │    Statement       │    │
- Rules        │   Rules     │     Builder        │    │
- ┴─────────────┴────────────────────┘    │

**┌─────────────────────────────────────────────────────┐   │**
- Assertion System                    │   │
- ┬─────────────────────────────┤   │
- Declaration          │         Relation             │   │
- Assertions          │        Assertions            │   │
- ┴─────────────────────────────┘   │

**┌─────────────────────────────────────────────────────┐   │**
- Selector System                    │   │
- ┤   │
- Class/Interface/Trait/Enum Selectors         │   │
- ┘   │

**┌─────────────────────────────────────────────────────┐   │**
- Parser System                      │   │
- ┘   │

**┌─────────────────────────────────────────────────────┐   │**
- Extractor System                    ◄───┘
- ┘

##### Key Elements to Highlight

a) Input/Output Flow:
- Test definitions input
- Configuration input
- Rule validation results output
- Error reporting output

b) Internal Processes:
- Test parsing and validation
- Rule execution flow
- Assertion verification
- Selector matching

##### Implementation Details

- Relationship between Rule, Assertion, and Selector components
- Separation between Declaration and Relation rules
- Extensibility points for custom rules
- Configuration integration points

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Core
        TR["Test Runner"]:::core
        RE["Rule Engine & Validator"]:::core
        AS["Assertion System"]:::core
        SS["Selector System"]:::core
        PS["Parser System"]:::core
        ES["Extractor System"]:::core
    end

    subgraph RuleComponents
        DR["Declaration Rules"]:::rule
        RR["Relation Rules"]:::rule
    end

    subgraph BuilderSystem
        SB["Statement Builder"]:::builder
        TB["Test Builder"]:::builder
    end

    subgraph AssertionTypes
        DA["Declaration Assertions"]:::assertion
        RA["Relation Assertions"]:::assertion
    end

    subgraph Support
        CH["Configuration Handler"]:::support
    end

    %% Main Flow
    TR --> RE
    RE --> AS
    RE --> SS
    RE --> PS
    RE --> ES

    %% Rule Components Integration
    RE --> DR
    RE --> RR
    DR --> AS
    RR --> AS

    %% Builder Integration
    SB --> RE
    TB --> TR

    %% Assertion Types
    AS --> DA
    AS --> RA

    %% Configuration Integration
    CH --> TR

    %% Styling
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef rule fill:#2ecc71,stroke:#27ae60,color:white
    classDef builder fill:#e74c3c,stroke:#c0392b,color:white
    classDef assertion fill:#9b59b6,stroke:#8e44ad,color:white
    classDef support fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Click Events
    click TR "https://github.com/carlosas/phpat/blob/master/src/Test/PHPat.php"
    click RE "https://github.com/carlosas/phpat/blob/master/src/Test/RuleValidator.php"
    click AS "https://github.com/carlosas/phpat/blob/master/src/Rule/Assertion/Assertion.php"
    click SS "https://github.com/carlosas/phpat/blob/master/src/Selector/Selector.php"
    click PS "https://github.com/carlosas/phpat/blob/master/src/Parser/TypeNodeParser.php"
    click ES "https://github.com/carlosas/phpat/tree/master/src/Rule/Extractor"
    click CH "https://github.com/carlosas/phpat/blob/master/src/Configuration.php"
    click SB "https://github.com/carlosas/phpat/blob/master/src/Statement/Builder/StatementBuilder.php"
    click TB "https://github.com/carlosas/phpat/blob/master/src/Test/Builder/AbstractStep.php"
    click DR "https://github.com/carlosas/phpat/tree/master/src/Rule/Assertion/Declaration"
    click RR "https://github.com/carlosas/phpat/tree/master/src/Rule/Assertion/Relation"
```
