PHPackages                             opencat/core - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. opencat/core

ActiveLibrary[Framework](/categories/framework)

opencat/core
============

Shared data models and contract interfaces for the OpenCAT Framework

00PHP

Since May 9Pushed 1mo agoCompare

[ Source](https://github.com/shaikhammar/opencat-core)[ Packagist](https://packagist.org/packages/opencat/core)[ RSS](/packages/opencat-core/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

opencat/core
============

[](#opencatcore)

Shared data models, contracts, and enums for the [OpenCAT Framework](https://github.com/shaikhammar/opencat-framework).

Every other OpenCAT package depends on this one. It contains no business logic — only the shapes that the rest of the framework passes around.

Installation
------------

[](#installation)

```
composer require opencat/core
```

Requires `ext-intl` and `ext-mbstring`.

What's inside
-------------

[](#whats-inside)

### Models

[](#models)

ClassPurpose`Segment`Ordered sequence of `string` and `InlineCode` elements — one translatable unit`SegmentPair`Source `Segment` + target `Segment` (null when untranslated), status, and lock flag`BilingualDocument`Ordered collection of `SegmentPair` objects plus filter skeleton data`InlineCode`A non-translatable formatting marker inside a `Segment` (bold tag, link, line break, etc.)`TranslationUnit`A stored source/target pair in a translation memory, with metadata`MatchResult`A TM lookup result — `TranslationUnit` plus similarity score and match type`QualityIssue`One issue raised by a QA check — check ID, severity, message, and character offset`TermEntry`A bilingual term pair from a glossary — source/target text, domain, and forbidden flag`TermMatch`A term found in running text — `TermEntry` plus the matched span### Contracts (interfaces)

[](#contracts-interfaces)

InterfaceImplemented by`FileFilterInterface`[`filter-plaintext`](https://github.com/shaikhammar/opencat-framework/tree/main/packages/filter-plaintext), [`filter-html`](https://github.com/shaikhammar/opencat-framework/tree/main/packages/filter-html), [`filter-docx`](https://github.com/shaikhammar/opencat-framework/tree/main/packages/filter-docx), others`SegmentationEngineInterface`[`segmentation`](https://github.com/shaikhammar/opencat-framework/tree/main/packages/segmentation)`TranslationMemoryInterface`[`translation-memory`](https://github.com/shaikhammar/opencat-framework/tree/main/packages/translation-memory)`MachineTranslationInterface`[`mt`](https://github.com/shaikhammar/opencat-framework/tree/main/packages/mt)`TerminologyProviderInterface`[`terminology`](https://github.com/shaikhammar/opencat-framework/tree/main/packages/terminology)`QualityCheckInterface`[`qa`](https://github.com/shaikhammar/opencat-framework/tree/main/packages/qa)`DocumentQualityCheckInterface`[`qa`](https://github.com/shaikhammar/opencat-framework/tree/main/packages/qa)### Enums

[](#enums)

EnumValues`SegmentStatus``Untranslated`, `Draft`, `Translated`, `Reviewed`, `Approved`, `Rejected``SegmentState`States for external interchange formats`InlineCodeType``OPENING`, `CLOSING`, `STANDALONE``MatchType``EXACT`, `EXACT_TEXT`, `FUZZY``QualitySeverity``INFO`, `WARNING`, `ERROR`### Exceptions

[](#exceptions)

Each domain has its own exception class extending `\RuntimeException`:

`FilterException` · `MtException` · `SegmentationException` · `TerminologyException` · `TmException`

Working with Segment
--------------------

[](#working-with-segment)

A `Segment` holds an ordered mix of plain strings and `InlineCode` objects:

```
use CatFramework\Core\Model\Segment;
use CatFramework\Core\Model\InlineCode;
use CatFramework\Core\Enum\InlineCodeType;

$bold = new InlineCode('b1', InlineCodeType::OPENING, '');
$boldClose = new InlineCode('b1', InlineCodeType::CLOSING, '');

$segment = new Segment('seg-1', [
    'Hello ',
    $bold,
    'world',
    $boldClose,
    '!',
]);

$segment->getPlainText();    // "Hello world!"
$segment->isEmpty();         // false
$segment->getInlineCodes();  // [$bold, $boldClose]
```

Working with BilingualDocument
------------------------------

[](#working-with-bilingualdocument)

```
use CatFramework\Core\Model\BilingualDocument;
use CatFramework\Core\Model\SegmentPair;
use CatFramework\Core\Enum\SegmentStatus;

$doc = new BilingualDocument(
    sourceLanguage: 'en-US',
    targetLanguage: 'fr-FR',
    originalFile: 'report.docx',
    mimeType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
);

foreach ($doc->getSegmentPairs() as $pair) {
    echo $pair->source->getPlainText();  // source text
    echo $pair->status->name;           // SegmentStatus enum name
    echo $pair->isLocked ? 'locked' : 'editable';
}
```

Implementing a custom file filter
---------------------------------

[](#implementing-a-custom-file-filter)

```
use CatFramework\Core\Contract\FileFilterInterface;
use CatFramework\Core\Model\BilingualDocument;
use CatFramework\Core\Exception\FilterException;

class MyFilter implements FileFilterInterface
{
    public function supports(string $filePath, ?string $mimeType = null): bool
    {
        return str_ends_with(strtolower($filePath), '.myext');
    }

    public function extract(string $filePath, string $sourceLanguage, string $targetLanguage): BilingualDocument
    {
        // parse $filePath, create and return a BilingualDocument
    }

    public function rebuild(BilingualDocument $document, string $outputPath): void
    {
        // use $document->skeleton to reconstruct the file
    }

    public function getSupportedExtensions(): array
    {
        return ['.myext'];
    }
}
```

Related packages
----------------

[](#related-packages)

- [`opencat/segmentation`](https://github.com/shaikhammar/opencat-framework/tree/main/packages/segmentation) — sentence segmentation using `SegmentationEngineInterface`
- [`opencat/translation-memory`](https://github.com/shaikhammar/opencat-framework/tree/main/packages/translation-memory) — TM using `TranslationMemoryInterface`
- [`opencat/mt`](https://github.com/shaikhammar/opencat-framework/tree/main/packages/mt) — machine translation using `MachineTranslationInterface`
- [`opencat/qa`](https://github.com/shaikhammar/opencat-framework/tree/main/packages/qa) — QA checks using `QualityCheckInterface`
- [`opencat/workflow`](https://github.com/shaikhammar/opencat-framework/tree/main/packages/workflow) — wires all of the above into one call

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance61

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/c6b9044413071860fd6199e56c661a24f449797b77a1b130f0df7e98be8481f4?d=identicon)[shaikhammar](/maintainers/shaikhammar)

---

Top Contributors

[![actions-user](https://avatars.githubusercontent.com/u/65916846?v=4)](https://github.com/actions-user "actions-user (3 commits)")

### Embed Badge

![Health badge](/badges/opencat-core/health.svg)

```
[![Health](https://phpackages.com/badges/opencat-core/health.svg)](https://phpackages.com/packages/opencat-core)
```

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k104.3M822](/packages/laravel-socialite)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k38.6M289](/packages/laravel-dusk)[pinguo/php-msf

Pinguo Micro Service Framework For PHP

1.7k4.2k](/packages/pinguo-php-msf)[nineinchnick/edatatables

Grid widget for the Yii Framework, wrapper for the DataTables jQuery plugin

173.2k](/packages/nineinchnick-edatatables)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
