2017 © Pedro Peláez
 

library stdlib

Standard Library for Selami libraries.

image

selami/stdlib

Standard Library for Selami libraries.

  • Wednesday, July 11, 2018
  • by mkorkmaz
  • Repository
  • 1 Watchers
  • 0 Stars
  • 252 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 11 Versions
  • 47 % Grown

The README.md

Selami Stdlib

Build Status Coverage Status Scrutinizer Code Quality, (*1)

Standard Library for Selami and other libraries., (*2)

EqualsBuilder

This class provides methods to build a equals method for any class. Intended to be use to compare Value Objects., (*3)

<?php 
declare(strict_types=1);

use Selami\Stdlib\EqualsBuilder;

class SomeValueObject()
{
    private $value1;
    private $value2;

    public function __construct(string $value1, string $value2)
    {
        $this->value1 = $value1;
        $this->value2 = $value2;
    }

    public function getValue1() :string 
    {
        return $value1;
    }

    public function getValue2() : string
    {
        return $value2;
    }

    public function equals($otherObject) : bool
    {
        return EqualsBuilder::create()
            ->append($this->value1, $otherObject->getValue1())
            ->append($this->value2, $otherObject->getValue2())
            ->isEquals(); 
    }
}

Resolver

This class provides a method to obtain typehints of a method. Intended to be used to autowire classes., (*4)

<?php
declare(strict_types=1);

use Selami\Stdlib\Resolver;

class BlogService {}

class Controller
{
    private $argument;
    private $service;
    public function __construct(BlogService $service, array $argument)
    {
        $this->service = $service;
        $this->argument = $argument;
    }
}

$arguments = Resolver::getParameterHints(Controller::class, '__construct');

var_dump($arguments);

/* Prints 
array(2) {
  ["service"]=>
  string(11) "BlogService"
  ["argument"]=>
  string(5) "array"
}
*/

CaseConverter

This class provides methods to convert strings to camelCase, PascalCase or snake_case string., (*5)

<?php
declare(strict_types=1);

use Selami\Stdlib\CaseConverter;

$source = 'test string';
$result = CaseConverter::toCamelCase($source); // returns: testString
$result = CaseConverter::toPascalCase($source); // returns: TestString
$result = CaseConverter::toSnakeCase($source); // returns: test_string

Git\Version

This class provides a methods to get short version of git. For deployments using git, it can be used to give version numbers to JS, CSS files to ensure to cache updated version of these files., (*6)

<?php // common.php

declare(strict_types=1);

use Selami\Stdlib\Git\Version;

$gitVersion = Version::short();

$twig->addGlobal('version', $gitVersion);

```html , (*7)

...


## BaseUrlExtractor This class provides a methods to get base url where applications runs. Caution: This method may not return real base url if you are behind some services like Cloudflare and when you use Flexible SSL feature. ```php <?php declare(strict_types=1); use Selami\Stdlib\BaseUrlExtractor; $baseUrl = BaseUrlExtractor::getBaseUrl($_SERVER); echo $baseUrl; /* Prints base url like: http://127.0.0.1:8080 http://127.0.0.1:8080/myapp https://myapp.com */

The Versions

11/07 2018

dev-master

9999999-dev

Standard Library for Selami libraries.

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

11/07 2018

1.6.2

1.6.2.0

Standard Library for Selami libraries.

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

11/07 2018

1.6.1

1.6.1.0

Standard Library for Selami libraries.

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

11/07 2018

1.6

1.6.0.0

Standard Library for Selami libraries.

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

21/09 2017

1.5

1.5.0.0

Standard Library for Selami libraries.

  Sources   Download

MIT

The Development Requires

18/09 2017

1.4

1.4.0.0

Standard Library for Selami libraries.

  Sources   Download

MIT

The Development Requires

17/07 2017

1.3

1.3.0.0

Standard Library for Selami libraries.

  Sources   Download

MIT

The Development Requires

16/07 2017

1.2.1

1.2.1.0

Standard Library for Selami libraries.

  Sources   Download

MIT

The Development Requires

14/07 2017

1.2

1.2.0.0

Standard Library for Selami libraries.

  Sources   Download

MIT

The Development Requires

13/07 2017

1.1

1.1.0.0

Standard Library for Selami libraries.

  Sources   Download

MIT

The Development Requires

13/07 2017

1.0

1.0.0.0

Standard Library for Selami libraries.

  Sources   Download

MIT

The Development Requires