Skip to content

Commit

Permalink
Merge pull request #6 from TheDragonCode/3.x
Browse files Browse the repository at this point in the history
[3.x] Changed namespace
  • Loading branch information
Andrey Helldar authored Nov 16, 2021
2 parents 59fde7b + 2d27bdd commit bc6629e
Show file tree
Hide file tree
Showing 24 changed files with 370 additions and 188 deletions.
1 change: 0 additions & 1 deletion .codecov.yml

This file was deleted.

39 changes: 0 additions & 39 deletions .github/workflows/coverage.yml

This file was deleted.

10 changes: 2 additions & 8 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [ "7.2", "7.3", "7.4", "8.0" ]
support: [ "2.0", "3.0", "4.0" ]
php: [ "7.3", "7.4", "8.0" ]

name: PHP ${{ matrix.php }}, Support ${{ matrix.support }}

Expand All @@ -24,13 +23,8 @@ jobs:
extensions: curl, mbstring, zip, pcntl, pdo, pdo_sqlite, iconv, bcmath
coverage: none

- name: Composer self update
run: composer self-update

- name: Install dependencies
run: |
composer require andrey-helldar/support:^${{ matrix.support }}
composer update --prefer-stable --prefer-dist --no-progress --no-interaction
run: composer update --prefer-stable --prefer-dist --no-progress --no-interaction

- name: Execute tests
run: sudo vendor/bin/phpunit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea/
build/
vendor/

tests/files/source.php.*.php
Expand Down
88 changes: 50 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
# Pretty Array

Simple conversion of an array to a pretty view.

<img src="https://preview.dragon-code.pro/TheDragonCode/pretty-array.svg?brand=php" alt="Pretty Array"/>

<p align="center">
<a href="https://packagist.org/packages/andrey-helldar/pretty-array"><img src="https://img.shields.io/packagist/dt/andrey-helldar/pretty-array.svg?style=flat-square" alt="Total Downloads" /></a>
<a href="https://packagist.org/packages/andrey-helldar/pretty-array"><img src="https://poser.pugx.org/andrey-helldar/pretty-array/v/stable?format=flat-square" alt="Latest Stable Version" /></a>
<a href="https://packagist.org/packages/andrey-helldar/pretty-array"><img src="https://poser.pugx.org/andrey-helldar/pretty-array/v/unstable?format=flat-square" alt="Latest Unstable Version" /></a>
</p>
[![Stable Version][badge_stable]][link_packagist]
[![Unstable Version][badge_unstable]][link_packagist]
[![Total Downloads][badge_downloads]][link_packagist]
[![Github Workflow Status][badge_build]][link_build]
[![License][badge_license]][link_license]

<p align="center">
<a href="https://styleci.io/repos/219764491"><img src="https://styleci.io/repos/219764491/shield" alt="StyleCI" /></a>
<a href="https://travis-ci.org/andrey-helldar/pretty-array"><img src="https://travis-ci.org/andrey-helldar/pretty-array.svg?branch=master" alt="Travis-CI" /></a>
<a href="LICENSE"><img src="https://poser.pugx.org/andrey-helldar/pretty-array/license?format=flat-square" alt="License" /></a>
</p>
> Simple conversion of an array to a pretty view.

## Installation

To get the latest version of `Pretty Array` package, simply require the project using [Composer](https://getcomposer.org):

```
composer require andrey-helldar/pretty-array --dev
composer require dragon-code/pretty-array
```

Instead, you may of course manually update your `require-dev` block and run `composer update` if you so choose:
Instead, you may of course manually update your `require` block and run `composer update` if you so choose:

```json
{
"require-dev": {
"andrey-helldar/pretty-array": "^2.2"
"require": {
"dragon-code/pretty-array": "^3.0"
}
}
```

### Upgrade from `andrey-helldar/pretty-array`

1. Replace `"andrey-helldar/pretty-array": "^2.0"` with `"dragon-code/pretty-array": "^3.0"` in the `composer.json` file;
2. Replace `Helldar\PrettyArray\Contracts\Caseable` with `DragonCode\Contracts\Pretty\Arr\Caseable`;
3. Replace `Helldar\PrettyArray` namespace prefix with `DragonCode\PrettyArray`;
4. Call the `composer update` console command.

## Introduction

> Q: Why did you create this package when there is a cooler [symfony/var-exporter](https://github.com/symfony/var-exporter)?
Expand Down Expand Up @@ -70,14 +71,15 @@ $array = [
> Q: Why do you think this is bad?
This package has a framework-independent base. However, it was originally developed as an assistant for
package [lang-translations](https://github.com/andrey-helldar/lang-translations).
the [Laravel Lang: HTTP Statuses](https://github.com/Laravel-Lang/http-statuses)
package.

This package allows you to publish language translations for the Laravel framework.
This package allows you to publish language translations of the HTTP Status Codes for the Laravel and Lumen frameworks.

A feature of the framework is that IDEs that help with development do not know how to read the numeric keys of arrays of translation files, so it was necessary to translate them
into a text equivalent.
A feature of the framework is that IDEs that help with development do not know how to read the numeric keys of arrays of translation files, so it was necessary to translate
theminto a text equivalent.

This behavior includes [errors.php](https://github.com/andrey-helldar/lang-translations/blob/master/src/lang/en/errors.php) file:
This behavior includes [http-statuses.php](https://github.com/Laravel-Lang/http-statuses/blob/main/source/http-statuses.php) file:

```php
<?php
Expand Down Expand Up @@ -159,7 +161,7 @@ $array = array (
### Saving numeric keys without alignment

```php
use Helldar\PrettyArray\Services\Formatter;
use DragonCode\PrettyArray\Services\Formatter;

$service = Formatter::make();

Expand Down Expand Up @@ -191,7 +193,7 @@ Result:
### Saving string keys without alignment

```php
use Helldar\PrettyArray\Services\Formatter;
use DragonCode\PrettyArray\Services\Formatter;

$service = Formatter::make();
$service->setKeyAsString();
Expand Down Expand Up @@ -224,7 +226,7 @@ Result:
### Saving numeric keys with alignment

```php
use Helldar\PrettyArray\Services\Formatter;
use DragonCode\PrettyArray\Services\Formatter;

$service = Formatter::make();
$service->setEqualsAlign();
Expand Down Expand Up @@ -257,7 +259,7 @@ Result:
### Saving string keys with alignment

```php
use Helldar\PrettyArray\Services\Formatter;
use DragonCode\PrettyArray\Services\Formatter;

$service = Formatter::make();
$service->setKeyAsString();
Expand Down Expand Up @@ -291,7 +293,7 @@ Result:
### Saving simple array

```php
use Helldar\PrettyArray\Services\Formatter;
use DragonCode\PrettyArray\Services\Formatter;

$service = Formatter::make();
$service->setSimple();
Expand Down Expand Up @@ -324,8 +326,8 @@ Result:
### Change key case

```php
use Helldar\PrettyArray\Contracts\Caseable;
use Helldar\PrettyArray\Services\Formatter;
use DragonCode\Contracts\Pretty\Arr\Caseable;
use DragonCode\PrettyArray\Services\Formatter;

$service = Formatter::make();
$service->setCase(Caseable::PASCAL_CASE);
Expand Down Expand Up @@ -357,20 +359,20 @@ Result:

The following options are available:

* camelCase (`Helldar\PrettyArray\Contracts\Caseable::CAMEL_CASE`);
* kebab-case (`Helldar\PrettyArray\Contracts\Caseable::KEBAB_CASE`);
* PascalCase (`Helldar\PrettyArray\Contracts\Caseable::PASCAL_CASE`);
* snake_case (`Helldar\PrettyArray\Contracts\Caseable::SNAKE_CASE`);
* no case (`Helldar\PrettyArray\Contracts\Caseable::NO_CASE`). By default;
* camelCase (`DragonCode\Contracts\Pretty\Arr\Caseable::CAMEL_CASE`);
* kebab-case (`DragonCode\Contracts\Pretty\Arr\Caseable::KEBAB_CASE`);
* PascalCase (`DragonCode\Contracts\Pretty\Arr\Caseable::PASCAL_CASE`);
* snake_case (`DragonCode\Contracts\Pretty\Arr\Caseable::SNAKE_CASE`);
* no case (`DragonCode\Contracts\Pretty\Arr\Caseable::NO_CASE`). By default;

`NO_CASE` means that key register processing will not be performed.


### Storing file

```php
use Helldar\PrettyArray\Services\File;
use Helldar\PrettyArray\Services\Formatter;
use DragonCode\PrettyArray\Services\File;
use DragonCode\PrettyArray\Services\Formatter;

$service = Formatter::make();

Expand Down Expand Up @@ -409,8 +411,18 @@ return [
This package is licensed under the [MIT License](LICENSE).


## For Enterprise
[badge_build]: https://img.shields.io/github/workflow/status/TheDragonCode/pretty-array/phpunit?style=flat-square

[badge_downloads]: https://img.shields.io/packagist/dt/dragon-code/pretty-array.svg?style=flat-square

[badge_license]: https://img.shields.io/packagist/l/dragon-code/pretty-array.svg?style=flat-square

[badge_stable]: https://img.shields.io/github/v/release/TheDragonCode/pretty-array?label=stable&style=flat-square

[badge_unstable]: https://img.shields.io/badge/unstable-dev--main-orange?style=flat-square

[link_build]: https://github.com/TheDragonCode/pretty-array/actions

Available as part of the Tidelift Subscription.
[link_license]: LICENSE

The maintainers of `andrey-helldar/pretty-array` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source packages you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use. [Learn more](https://tidelift.com/subscription/pkg/packagist-andrey-helldar-pretty-array?utm_source=packagist-andrey-helldar-pretty-array&utm_medium=referral&utm_campaign=enterprise&utm_term=repo).
[link_packagist]: https://packagist.org/packages/dragon-code/pretty-array
5 changes: 0 additions & 5 deletions SECURITY.md

This file was deleted.

22 changes: 13 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "andrey-helldar/pretty-array",
"description": "Simple conversion of an array to a pretty view.",
"name": "dragon-code/pretty-array",
"description": "Simple conversion of an array to a pretty view",
"type": "library",
"license": "MIT",
"keywords": ["pretty array", "pretty", "array"],
"keywords": ["pretty array", "pretty", "array", "dragon code", "dragon", "andrey helldar"],
"support": {
"issues": "https://github.com/andrey-helldar/pretty-array/issues",
"source": "https://github.com/andrey-helldar/pretty-array"
"issues": "https://github.com/TheDragonCode/pretty-array/issues",
"source": "https://github.com/TheDragonCode/pretty-array"
},
"authors": [
{
Expand All @@ -15,20 +15,24 @@
}
],
"require": {
"php": "^7.2.5|^8.0",
"php": "^7.3|^8.0",
"ext-dom": "*",
"ext-mbstring": "*",
"andrey-helldar/support": "^2.0|^3.0|^4.0"
"dragon-code/contracts": "^2.6",
"dragon-code/support": "^5.0"
},
"require-dev": {
"phpunit/phpunit": "^8.0|^9.0"
"phpunit/phpunit": "^9.0"
},
"conflict": {
"andrey-helldar/pretty-array": "*"
},
"suggest": {
"symfony/thanks": "Give thanks (in the form of a GitHub) to your fellow PHP package maintainers"
},
"autoload": {
"psr-4": {
"Helldar\\PrettyArray\\": "src"
"DragonCode\\PrettyArray\\": "src"
}
},
"autoload-dev": {
Expand Down
16 changes: 16 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ This file is part of the "dragon-code/pretty-array" project.
~
~ For the full copyright and license information, please view the LICENSE
~ file that was distributed with this source code.
~
~ @author Andrey Helldar <[email protected]>
~
~ @copyright 2021 Andrey Helldar
~
~ @license MIT
~
~ @see https://github.com/TheDragonCode/pretty-array
-->

<phpunit
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand Down
23 changes: 19 additions & 4 deletions src/Concerns/HasCases.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
<?php

namespace Helldar\PrettyArray\Concerns;
/*
* This file is part of the "dragon-code/pretty-array" project.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Andrey Helldar <[email protected]>
*
* @copyright 2021 Andrey Helldar
*
* @license MIT
*
* @see https://github.com/TheDragonCode/pretty-array
*/

use Helldar\PrettyArray\Exceptions\UnknownCaseTypeException;
use Helldar\Support\Facades\Helpers\Str;
namespace DragonCode\PrettyArray\Concerns;

use DragonCode\PrettyArray\Exceptions\UnknownCaseTypeException;
use DragonCode\Support\Facades\Helpers\Str;

trait HasCases
{
Expand All @@ -12,7 +27,7 @@ trait HasCases
/**
* @param int $type
*
* @throws \Helldar\PrettyArray\Exceptions\UnknownCaseTypeException
* @throws \DragonCode\PrettyArray\Exceptions\UnknownCaseTypeException
*/
public function setCase(int $type = self::NO_CASE): void
{
Expand Down
Loading

0 comments on commit bc6629e

Please sign in to comment.