Meritoo 463ee751b2 Readme - TravisCI badge - do not support nightly build of PHP, because friendsofphp/php-cs-fixer pacakge cane be run using maximum PHP 7.2
Details:
$ composer install
Your requirements could not be resolved to an installable set of packages
friendsofphp/php-cs-fixer v2.3.2 requires php ^5.6 || >=7.0 <7.2 -> your PHP version (7.3.0-dev) does not satisfy that requirement
2017-09-19 17:55:41 +02:00
2017-08-29 22:51:31 +02:00
2017-08-30 21:07:53 +02:00
2017-08-29 22:51:31 +02:00
2017-08-29 22:51:31 +02:00
2017-08-29 22:51:31 +02:00

Meritoo Common Library Travis Packagist StyleCI license GitHub commits Coverage Status

Useful classes, methods, extensions etc.

Installation

Run Composer to install new package:

```bash
$ composer require meritoo/common-library
```

How to install Composer: https://getcomposer.org/download

Static methods

This package contains a lot of class with static methods, so usage is not so complicated. Just run the static method who would you like to use. Example:

use Meritoo\Common\Utilities\Arrays;

$firstElement = Arrays::getFirstElement(['lorem', 'ipsum']);
var_dump($firstElement); // string(5) "lorem"

Base test case with common methods and data providers

Located here: Meritoo\Common\Test\Base\BaseTestCase. Just extend the BaseTestCase class and use it like in Meritoo\Common\Test\Utilities\DateTest class:

class DateTest extends BaseTestCase
{
    /**
     * @param mixed $value Empty value, e.g. ""
     * @dataProvider provideEmptyValue
     */
    public function testGetDateTimeEmptyValue($value)
    {
        self::assertFalse(Date::getDateTime($value));
    }

	(...)
}

or in Meritoo\Common\Test\Utilities\MimeTypesTest class:

class MimeTypesTest extends BaseTestCase
{
	(...)

    /**
     * @param bool $mimeType The mime type, e.g. "video/mpeg"
     * @dataProvider provideBooleanValue
     */
    public function testGetExtensionBooleanMimeType($mimeType)
    {
        self::assertEquals('', MimeTypes::getExtension($mimeType));
    }

	(...)
}

Collection of elements

Located here: Meritoo\Common\Collection\Collection. It's a set of some elements, e.g. objects. It's iterable and countable. Provides very useful methods. Some of them:

  • getFirst() - returns the first element in the collection
  • getLast() - returns the last element in the collection
  • isEmpty() - returns information if collection is empty
  • add($element, $index = null) - adds given element (at the end of collection)
  • addMultiple($elements, $useIndexes = false) - adds given elements (at the end of collection)
  • prepend($element) - prepends given element (adds given element at the beginning of collection)
  • remove($element) - removes given element

Examples of usage below.

An empty collection

use Meritoo\Common\Collection\Collection;

$emptyCollection = new Collection();
var_dump($emptyCollection->isEmpty()); // bool(true)

Simple collection

use Meritoo\Common\Collection\Collection;

$elements = [
    'lorem',
    'ipsum',
    123 => 'dolor',
    345 => 'sit',
];

$simpleCollection = new Collection($elements);
var_dump($simpleCollection->has('dolor')); // bool(true)

Enjoy!

Description
PHP Library for using with Limesurvey-api-client
Readme MIT 951 KiB
Languages
PHP 99.5%
Dockerfile 0.4%