valksor / php-functions-queue
A PHP library providing a simple and efficient queue implementation for managing collections of items in a FIFO (First-In-First-Out) manner
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/valksor/php-functions-queue
Requires
- php: >=8.4
Suggests
This package is auto-updated.
Last update: 2025-10-29 19:31:58 UTC
README
A PHP library providing a simple and efficient queue implementation for managing collections of items in a FIFO (First-In-First-Out) manner.
Installation
Install the package via Composer:
composer require valksor/php-functions-queue
Requirements
PHP 8.4 or higher
Usage
The Queue class provides a simple implementation of a FIFO (First-In-First-Out) queue data structure.
use Valksor\Functions\Queue\Queue; // Create a new Queue instance $queue = new Queue(); // Add items to the queue $queue->push(1); $queue->push(2); $queue->push(3); // Check if the queue contains an item $containsTwo = $queue->contains(2); // true // Get the number of items in the queue $count = count($queue); // 3 // Check if the queue is empty $isEmpty = $queue->isEmpty(); // false // Get the first item without removing it $firstItem = $queue->peek(); // 1 // Remove and return the first item $firstItem = $queue->pop(); // 1 // Clear all items from the queue $queue->clear();
You can also initialize a queue with an array of items:
// Create a queue with initial items $queue = new Queue([1, 2, 3]); // Get the number of items echo count($queue); // 3
Features
- FIFO implementation: Standard First-In-First-Out queue behavior
- Array initialization: Create queues from existing arrays
- Item management: Add, remove, and check for items
- Queue inspection: Peek at items without removing them
- Count support: Use count() to get queue length
- Clear functionality: Remove all items at once
- Simple API: Intuitive and easy-to-use interface
For a complete list of all methods available in this package, see Features.
Contributing
Contributions are welcome! Please read our Contributing Guidelines for details on:
- Code style requirements (PSR-12)
- Testing requirements for PRs
- One feature per pull request
- Development setup instructions
To contribute to Queue functions:
- Fork repository
- Create a feature branch (git checkout -b feature/new-queue-function)
- Implement your function following existing patterns
- Add comprehensive tests including edge cases
- Ensure all tests pass and code style is correct
- Submit a pull request
Security
If you discover any security-related issues, please email us at security@valksor.dev instead of using the issue tracker.
For security policy and vulnerability reporting guidelines, please see our Security Policy.
Support
- Documentation: Full documentation
- Issues: GitHub Issues for bug reports and feature requests
- Discussions: GitHub Discussions for questions and community support
- Stack Overflow: Use tag valksor-php-functions-queue
Credits
- Original Author - Creator and maintainer
- All Contributors - Thank you to all who contributed
- Relevant PHP Documentation - Core PHP functionality inspiration
- Valksor Project - Part of the larger Valksor PHP ecosystem
License
This package is licensed under the BSD-3-Clause License.
About Valksor
This package is part of the valksor/php-valksor project - a comprehensive PHP library and Symfony bundle that provides a collection of utilities, components, and integrations for Symfony applications.
The main project includes:
- Various utility functions and components
- Doctrine ORM tools and extensions
- Symfony bundle for easy configuration
- And much more
If you find this Queue component useful, you might want to check out the full Valksor project for additional tools and utilities that can enhance your Symfony application development.
To install the complete package:
composer require valksor/php-valksor