# drewm/morse architecture

> Architecture diagram of the GitHub repository drewm/morse, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/drewm/morse
- Repository: https://github.com/drewm/morse

## Overview

##### Project Type Understanding
This is a specialized PHP library focused on feature detection, designed to help developers determine available functionality in different PHP environments. It's a utility library that serves as a middleware/helper component in larger PHP applications.

##### Main Components

a) Core Component:
- This handles the main feature detection logic and API

b) Feature Groups:
- Cache Features
- Crypto Features
- Data Features
- Database Features
- File Features
- HTTP Features
- Image Features
- Number Features
- Protocol Features
- System Features
- Text Features

##### Architectural Representation

Layer 1 (Center):

Layer 2 (Middle Ring):
- Feature abstract class (src/Feature.php)
- It as an intermediary between core and specific features

Layer 3 (Outer Ring):
- Individual feature category components
- Each containing its specific detection methods

##### Connection and Flow Representation

- Inheritance relationships (Feature classes extending the base Feature class)
- API flow (how feature detection requests flow from client code through the system)

- Use blue for the core component
- Use green for the Feature abstract class
- Use yellow for feature category components
- Use gray for external systems being detected

##### Specific Elements

**Morse::featureExists('group/feature')**
**Morse::getFirstAvailable([features])**

- Boolean (true/false)
- Morse::CLASS_SUPPORT
- Morse::FUNCTION_SUPPORT

c) Feature Detection Flow:

##### Technical Details

- Namespace structure (DrewM\Morse)
- Composer integration point
- Points where environment detection occurs
- Function availability checking mechanism

**if (Morse::featureExists('http/curl')) {**
- // curl available
**} else {**
- // alternative implementation
**}**

This will give other developers a clear understanding of both the architecture and the practical application of the library.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Core
        MC["Morse Core"]
        FB["Feature Base Class"]
        MC --> FB
    end

    subgraph "Feature Categories"
        CF["Cache Features"]
        CRF["Crypto Features"]
        DF["Data Features"]
        DBF["Database Features"]
        FF["File Features"]
        HF["HTTP Features"]
        IF["Image Features"]
        NF["Number Features"]
        PF["Protocol Features"]
        SF["System Features"]
        TF["Text Features"]
    end

    FB --> CF & CRF & DF & DBF & FF & HF & IF & NF & PF & SF & TF

    subgraph "Test Suite"
        MT["Core Tests"]
        CT["Cache Tests"]
        CRT["Crypto Tests"]
        DT["Data Tests"]
        DBT["Database Tests"]
        FT["File Tests"]
        HT["HTTP Tests"]
        IT["Image Tests"]
        NT["Number Tests"]
        PT["Protocol Tests"]
        ST["System Tests"]
        TT["Text Tests"]
    end

    CF --> CT
    CRF --> CRT
    DF --> DT
    DBF --> DBT
    FF --> FT
    HF --> HT
    IF --> IT
    NF --> NT
    PF --> PT
    SF --> ST
    TF --> TT
    MC --> MT

    subgraph "Usage Example"
        UI["if (Morse::featureExists('http/curl')) {
            // curl available
        } else {
            // alternative implementation
        }"]
    end

    subgraph "Return Types"
        RT["Boolean (true/false)
        Morse::CLASS_SUPPORT
        Morse::FUNCTION_SUPPORT"]
    end

    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef feature fill:#2ecc71,stroke:#27ae60,color:white
    classDef category fill:#f1c40f,stroke:#f39c12,color:black
    classDef test fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef example fill:#e74c3c,stroke:#c0392b,color:white

    class MC,UI core
    class FB feature
    class CF,CRF,DF,DBF,FF,HF,IF,NF,PF,SF,TF category
    class MT,CT,CRT,DT,DBT,FT,HT,IT,NT,PT,ST,TT test
    class RT example

    click MC "https://github.com/drewm/morse/blob/master/src/Morse.php"
    click FB "https://github.com/drewm/morse/blob/master/src/Feature.php"
    click CF "https://github.com/drewm/morse/blob/master/src/Feature/Cache.php"
    click CRF "https://github.com/drewm/morse/blob/master/src/Feature/Crypto.php"
    click DF "https://github.com/drewm/morse/blob/master/src/Feature/Data.php"
    click DBF "https://github.com/drewm/morse/blob/master/src/Feature/Db.php"
    click FF "https://github.com/drewm/morse/blob/master/src/Feature/File.php"
    click HF "https://github.com/drewm/morse/blob/master/src/Feature/Http.php"
    click IF "https://github.com/drewm/morse/blob/master/src/Feature/Image.php"
    click NF "https://github.com/drewm/morse/blob/master/src/Feature/Number.php"
    click PF "https://github.com/drewm/morse/blob/master/src/Feature/Protocol.php"
    click SF "https://github.com/drewm/morse/blob/master/src/Feature/System.php"
    click TF "https://github.com/drewm/morse/blob/master/src/Feature/Text.php"
    click MT "https://github.com/drewm/morse/blob/master/tests/MorseTest.php"
    click CT "https://github.com/drewm/morse/blob/master/tests/CacheTest.php"
    click CRT "https://github.com/drewm/morse/blob/master/tests/CryptoTest.php"
    click DT "https://github.com/drewm/morse/blob/master/tests/DataTest.php"
    click DBT "https://github.com/drewm/morse/blob/master/tests/DbTest.php"
    click FT "https://github.com/drewm/morse/blob/master/tests/FileTest.php"
    click HT "https://github.com/drewm/morse/blob/master/tests/HttpTest.php"
    click IT "https://github.com/drewm/morse/blob/master/tests/ImageTest.php"
    click NT "https://github.com/drewm/morse/blob/master/tests/NumberTest.php"
    click PT "https://github.com/drewm/morse/blob/master/tests/ProtocolTest.php"
    click ST "https://github.com/drewm/morse/blob/master/tests/SystemTest.php"
    click TT "https://github.com/drewm/morse/blob/master/tests/TextTest.php"
```
