germania-kg / downloads
Requires
- php: ^7.4|^8.0
- container-interop/container-interop: ^1.1
- germania-kg/categories: ^1.0
- germania-kg/worlds: ^2.0
Requires (Dev)
- phpspec/prophecy: ^1.16
- phpstan/phpstan: ^1.9
- phpunit/phpunit: ^9.0
- satooshi/php-coveralls: ^1.0
This package is auto-updated.
Last update: 2024-12-09 18:47:41 UTC
README
This package was destilled from legacy code!
You better do not want it to use this in production.
Installation with Composer
$ composer require germania-kg/downloads
MySQL: This package requires some MySQL tables downloads, downloads_categories_mm and downloads_worlds_mm which you can install using germania_downloads.sql
in sql/
directory.
Usage
While the Downloads class is a simple storage, PdoDownloads reads all downloads from the database. They both implement the container-interop (upcoming PSR 11 standard), IteratorAggregate and SPL's Countable.
You can iterate over it all worlds due to its interface, and you can retrieve single Download instances:
<?php use Germania\Downloads\Downloads; use Germania\Downloads\PdoDownloads; use Germania\Downloads\Download; $downloads = new Downloads( ); $download = new Download; $download->setUrl( 'http://...' ); $downloads->push( $download ); // Or, get all from PDO datebase: $downloads = new PdoDownloads( $pdo ); // Check on ID and retrieve $check = $downloads->has( 42 ); $my_download = $downloads->get( 42 ); echo $my_download->getUrl(); ?>
Development
$ git clone https://github.com/GermaniaKG/Downloads.git
$ cd Downloads
$ composer install
Unit tests
Either copy phpunit.xml.dist
to phpunit.xml
and adapt to your needs, or leave as is. Run PhpUnit test or composer scripts like this:
$ composer test # or $ vendor/bin/phpunit