PHPackages                             kariricode/contract - 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. kariricode/contract

ActiveLibrary[Framework](/categories/framework)

kariricode/contract
===================

Central repository for interface definitions in the KaririCode Framework. Implements interface code in PHP for specified namespaces, adhering to PSR standards and leveraging modern PHP features.

v2.8.6(10mo ago)01.7k6MITPHPPHP ^8.3CI failing

Since Jun 27Pushed 10mo agoCompare

[ Source](https://github.com/KaririCode-Framework/kariricode-contract)[ Packagist](https://packagist.org/packages/kariricode/contract)[ Docs](https://kariricode.org/)[ RSS](/packages/kariricode-contract/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (6)Versions (36)Used By (6)

KaririCode Framework: Contract Component
========================================

[](#kariricode-framework-contract-component)

[![en](https://camo.githubusercontent.com/9687410941adb91c2f673c9d50ef38544f3e9a38a6b9f9367cac918a8d3e2a41/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c616e672d656e2d7265642e737667)](README.md)[![pt-br](https://camo.githubusercontent.com/03443f2a7a42ea03f0747d7bb784c5e42ee3f2c09e27bab66436a5021cc05c0c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c616e672d70742d2d62722d677265656e2e737667)](README.pt-br.md)

[![Docker](https://camo.githubusercontent.com/85e3ff712bb08b8e5595b34ecddfd189a51b20f61988aa467a56c5da9a107dda/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f636b65722d3234393645443f7374796c653d666f722d7468652d6261646765266c6f676f3d646f636b6572266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/85e3ff712bb08b8e5595b34ecddfd189a51b20f61988aa467a56c5da9a107dda/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f636b65722d3234393645443f7374796c653d666f722d7468652d6261646765266c6f676f3d646f636b6572266c6f676f436f6c6f723d7768697465)[![Makefile](https://camo.githubusercontent.com/a04b8a060bf2e39eb19daa633fb06ec15cd6247035ce3c168127a37d7cadaad4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d616b6566696c652d3144314431443f7374796c653d666f722d7468652d6261646765266c6f676f3d676e75266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/a04b8a060bf2e39eb19daa633fb06ec15cd6247035ce3c168127a37d7cadaad4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d616b6566696c652d3144314431443f7374796c653d666f722d7468652d6261646765266c6f676f3d676e75266c6f676f436f6c6f723d7768697465)[![PHP](https://camo.githubusercontent.com/d282cc3193faee11ee32307d0c4c9d809e8fafa4b3a8c12c6afbf35d4f7ec617/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d3737374242343f7374796c653d666f722d7468652d6261646765266c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/d282cc3193faee11ee32307d0c4c9d809e8fafa4b3a8c12c6afbf35d4f7ec617/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d3737374242343f7374796c653d666f722d7468652d6261646765266c6f676f3d706870266c6f676f436f6c6f723d7768697465)[![PHPUnit](https://camo.githubusercontent.com/1a56a0e0e8f226512ca8ebf712fae233ef290ab1acbe601f48ada7817583878b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f504850556e69742d3738453133303f7374796c653d666f722d7468652d6261646765266c6f676f3d706870756e6974266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/1a56a0e0e8f226512ca8ebf712fae233ef290ab1acbe601f48ada7817583878b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f504850556e69742d3738453133303f7374796c653d666f722d7468652d6261646765266c6f676f3d706870756e6974266c6f676f436f6c6f723d7768697465)

Overview
--------

[](#overview)

The Contract component is a fundamental part of the KaririCode Framework, providing a comprehensive set of interfaces that define contracts for various data structures and behaviors. These interfaces serve as the foundation for implementing robust, consistent, and interoperable data structure components within and beyond the KaririCode ecosystem.

Key Features
------------

[](#key-features)

- **Comprehensive Set of Interfaces**: Covers a wide range of data structures and behaviors.
- **Type Safety**: Leverages PHP 8.3+ features for better type checking and higher code reliability.
- **Flexibility**: Allows multiple implementations of the same interface, promoting code reuse and modularity.
- **Standardization**: Provides a consistent API across different implementations.

Available Interfaces and Their Applications
-------------------------------------------

[](#available-interfaces-and-their-applications)

### Structural Interfaces

[](#structural-interfaces)

#### Collection

[](#collection)

Defines the contract for a collection of elements. Ideal for implementing lists, sets, and other custom collections.

**Suggested Applications:**

- Implementing a product catalog in an e-commerce site.
- Managing a task list in a productivity app.

#### Map

[](#map)

Defines the contract for map data structures, which store key-value pairs.

**Suggested Applications:**

- Implementing an in-memory data cache.
- Managing user sessions in a web application.

#### Set

[](#set)

Defines the contract for set data structures, which do not allow duplicate elements.

**Suggested Applications:**

- Maintaining a unique list of tags in a blog system.
- Implementing a spam filter based on IP addresses.

#### Queue

[](#queue)

Defines the contract for queue data structures, which follow the FIFO (First-In-First-Out) principle.

**Suggested Applications:**

- Order processing system in a restaurant.
- Task management in a print system.

#### Stack

[](#stack)

Defines the contract for stack data structures, which follow the LIFO (Last-In-First-Out) principle.

**Suggested Applications:**

- Implementing a browser history in a web browser.
- Managing function calls in a programming language interpreter.

#### Tree

[](#tree)

Defines the contract for tree data structures.

**Suggested Applications:**

- Representing hierarchical structures such as product categories.
- Implementing a virtual file system.

#### Heap

[](#heap)

Defines the contract for heap data structures.

**Suggested Applications:**

- Implementing a priority queue in a customer service system.
- Optimizing sorting and search algorithms.

#### Deque

[](#deque)

Extends the Queue interface to define the contract for double-ended queue structures.

**Suggested Applications:**

- Implementing a circular buffer for stream processing.
- Developing a card game where cards can be added or removed from both ends.

### Behavioral Interfaces

[](#behavioral-interfaces)

#### Countable, Indexable, Modifiable, Searchable

[](#countable-indexable-modifiable-searchable)

These interfaces define common behaviors that can be applied to various data structures.

**Suggested Applications:**

- Implementing custom collections with specific functionalities.
- Developing wrappers for existing data structures to add new features.

#### Sortable, Comparable

[](#sortable-comparable)

Define contracts for objects that can be sorted and compared.

**Suggested Applications:**

- Implementing custom sorting algorithms.
- Developing ordered data structures, such as binary search trees.

#### IterableCollection, Iterator

[](#iterablecollection-iterator)

Provide the ability to iterate over a collection.

**Suggested Applications:**

- Implementing custom collections that can be used in foreach loops.
- Developing specialized iterators to traverse complex data structures.

### Specialized Interfaces

[](#specialized-interfaces)

#### BPlusTreeCollection

[](#bplustreecollection)

Defines the contract for B+ tree data structures.

**Suggested Applications:**

- Implementing database indexes for fast queries.
- Optimizing file systems for quick access to large volumes of data.

#### Serializable

[](#serializable)

Defines the contract for serializing and deserializing data.

**Suggested Applications:**

- Implementing a cache system that can store complex objects.
- Developing a custom data persistence mechanism.

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

[](#installation)

### Requirements

[](#requirements)

- PHP 8.3 or higher
- Composer

### Via Composer

[](#via-composer)

```
composer require kariricode/contract
```

Usage
-----

[](#usage)

To use these interfaces in your project, simply implement them in your classes. For example:

```
use KaririCode\Contract\DataStructure\Collection;

class MyCollection implements Collection
{
    // Implement the methods defined in the Collection interface
}
```

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

Support and Community
---------------------

[](#support-and-community)

- **Documentation**:
- **Issue Tracker**: [GitHub Issues](https://github.com/KaririCode-Framework/kariricode-contract/issues)
- **Community**: [KaririCode Club Community](https://kariricode.club)
- **Professional Support**: For enterprise-level support, contact us at

Acknowledgments
---------------

[](#acknowledgments)

- The KaririCode Framework team and contributors.
- The PHP community for their continuous support and inspiration.

---

Built with ❤️ by the KaririCode team. Empowering developers to build more robust and flexible PHP applications.

Maintained by Walmir Silva -

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance54

Moderate activity, may be stable

Popularity15

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity67

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~12 days

Recently: every ~72 days

Total

34

Last Release

316d ago

Major Versions

v1.0.1 → v2.0.02024-06-28

### Community

Maintainers

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

---

Top Contributors

[![walmir-silva](https://avatars.githubusercontent.com/u/142913591?v=4)](https://github.com/walmir-silva "walmir-silva (98 commits)")

---

Tags

frameworkframework-phpinterfacesphpphpframeworkinterfacecontractPSRskariri

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/kariricode-contract/health.svg)

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

PHPackages © 2026

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