# skillshare/formatphp architecture

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

- Interactive diagram: https://gitdiagram.com/skillshare/formatphp
- Repository: https://github.com/skillshare/formatphp

## Overview

##### Main Components Identification

The system can be broken down into these primary components:

a) Core Components:
- FormatPHP (main entry point)
- Config System
- Message System
- Descriptor System

b) Formatting Components:
- ICU Message Format
- Intl Formatters
- PseudoLocale System

c) Extraction System:
- Message Extractor
- Parser System
- Format Readers/Writers

##### Component Relationships

**[Client Application]**
- ↓
- [FormatPHP]
- ↓
- ┌─────┴─────┐
**[Config]    [Formatters]**

**[Messages]←─────┘**

**[Extractors]**

**[Parsers]**

**[Readers/Writers]**

##### Detailed Component Breakdown

a) Formatter Layer:
**[Intl Formatters]**
- DateTimeFormat
- NumberFormat
- DisplayNames
- MessageFormat

b) Message Processing Layer:
**[Message System]**
- MessageCollection
- MessageLoader
- MessageInterface

c) ICU Integration Layer:
**[ICU Message Format]**
- Parser
- Printer
- Validator

##### Implementation Details

- ICU dependency (version 69.1+)
- PHP intl extension integration
- CLDR and ICU Message syntax support
- Format reader/writer implementations (Chrome, Crowdin, Smartling, etc.)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client ["Client Application"]
        App[Application]
    end

    subgraph Core ["Core Layer"]
        FormatPHP["FormatPHP"]:::core
        Config["Config System"]:::core
        Descriptor["Descriptor System"]:::core
    end

    subgraph Messages ["Message Layer"]
        MessageSystem["Message System"]:::msg
        MessageCollection["Message Collection"]:::msg
        MessageLoader["Message Loader"]:::msg
    end

    subgraph Formatting ["Formatting Layer"]
        ICU["ICU Message Format"]:::fmt
        Parser["Parser"]:::fmt
        Printer["Printer"]:::fmt
        Validator["Validator"]:::fmt
        
        subgraph Formatters ["Intl Formatters"]
            DateTime["DateTime Format"]:::fmt
            Number["Number Format"]:::fmt
            Display["Display Names"]:::fmt
            MsgFormat["Message Format"]:::fmt
        end
    end

    subgraph Extraction ["Extraction Layer"]
        Extractor["Message Extractor"]:::extract
        ParserSystem["Parser System"]:::extract
        
        subgraph IO ["Format IO"]
            Readers["Format Readers"]:::io
            Writers["Format Writers"]:::io
        end
    end

    subgraph External ["External Dependencies"]
        ICULib["ICU Library"]:::ext
        IntlExt["PHP Intl Extension"]:::ext
        CLDR["CLDR Data"]:::ext
    end

    %% Relationships
    App --> FormatPHP
    FormatPHP --> Config
    FormatPHP --> Descriptor
    FormatPHP --> MessageSystem
    MessageSystem --> MessageCollection
    MessageSystem --> MessageLoader
    MessageSystem --> ICU
    ICU --> Parser
    ICU --> Printer
    ICU --> Validator
    ICU --> Formatters
    Formatters --> DateTime
    Formatters --> Number
    Formatters --> Display
    Formatters --> MsgFormat
    MessageSystem --> Extractor
    Extractor --> ParserSystem
    ParserSystem --> Readers
    ParserSystem --> Writers
    ICU --> ICULib
    ICU --> IntlExt
    ICU --> CLDR

    %% Click Events
    click FormatPHP "https://github.com/Skillshare/formatphp/blob/main/src/FormatPHP.php"
    click Config "https://github.com/Skillshare/formatphp/blob/main/src/Config.php"
    click MessageSystem "https://github.com/Skillshare/formatphp/blob/main/src/Message.php"
    click MessageCollection "https://github.com/Skillshare/formatphp/blob/main/src/MessageCollection.php"
    click MessageLoader "https://github.com/Skillshare/formatphp/blob/main/src/MessageLoader.php"
    click Descriptor "https://github.com/Skillshare/formatphp/blob/main/src/Descriptor.php"
    click Parser "https://github.com/Skillshare/formatphp/blob/main/src/Icu/MessageFormat/Parser.php"
    click Printer "https://github.com/Skillshare/formatphp/blob/main/src/Icu/MessageFormat/Printer.php"
    click Validator "https://github.com/Skillshare/formatphp/blob/main/src/Icu/MessageFormat/Validator.php"
    click DateTime "https://github.com/Skillshare/formatphp/blob/main/src/Intl/DateTimeFormat.php"
    click Number "https://github.com/Skillshare/formatphp/blob/main/src/Intl/NumberFormat.php"
    click Display "https://github.com/Skillshare/formatphp/blob/main/src/Intl/DisplayNames.php"
    click MsgFormat "https://github.com/Skillshare/formatphp/blob/main/src/Intl/MessageFormat.php"
    click Extractor "https://github.com/Skillshare/formatphp/blob/main/src/Extractor/MessageExtractor.php"
    click ParserSystem "https://github.com/Skillshare/formatphp/tree/main/src/Extractor/Parser"
    click Readers "https://github.com/Skillshare/formatphp/tree/main/src/Format/Reader"
    click Writers "https://github.com/Skillshare/formatphp/tree/main/src/Format/Writer"

    %% Styles
    classDef core fill:#2374ab,stroke:#2374ab,color:#fff
    classDef msg fill:#48a9a6,stroke:#48a9a6,color:#fff
    classDef fmt fill:#4ea5d9,stroke:#4ea5d9,color:#fff
    classDef extract fill:#e4572e,stroke:#e4572e,color:#fff
    classDef io fill:#f3a712,stroke:#f3a712,color:#fff
    classDef ext fill:#686963,stroke:#686963,color:#fff

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Message Components"]:::msg
        L3["Format Components"]:::fmt
        L4["Extraction Components"]:::extract
        L5["IO Components"]:::io
        L6["External Dependencies"]:::ext
    end
```
