germania-kg/downloads

1.1.0 2023-01-09 14:43 UTC

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.

Packagist Tests

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