Skip to content

Commit

Permalink
Merge pull request #22 from cPintiuta/issue-20
Browse files Browse the repository at this point in the history
Issue 20
  • Loading branch information
arhimede committed Jul 19, 2023
2 parents 2d94b10 + 398a562 commit 4c39fef
Show file tree
Hide file tree
Showing 22 changed files with 892 additions and 163 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/cs-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
on:
- push

name: Run phpcs checks

jobs:
mutation:
name: PHP ${{ matrix.php }}-${{ matrix.os }}

runs-on: ${{ matrix.os }}

strategy:
matrix:
os:
- ubuntu-latest

php:
- "8.1"
- "8.2"

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
tools: composer:v2, cs2pr
coverage: none

- name: Determine composer cache directory
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV

- name: Cache dependencies installed with composer
uses: actions/cache@v3
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
php${{ matrix.php }}-composer-
- name: Install dependencies with composer
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Run phpcs checks
run: vendor/bin/phpcs
46 changes: 46 additions & 0 deletions .github/workflows/static-analisys.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
on:
- push

name: Run static analysis

jobs:
mutation:
name: PHP ${{ matrix.php }}-${{ matrix.os }}

runs-on: ${{ matrix.os }}

strategy:
matrix:
os:
- ubuntu-latest

php:
- "8.1"
- "8.2"

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
tools: composer:v2, cs2pr
coverage: none

- name: Determine composer cache directory
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV

- name: Cache dependencies installed with composer
uses: actions/cache@v3
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
php${{ matrix.php }}-composer-
- name: Install dependencies with composer
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Run static analysis
run: vendor/bin/psalm --no-cache --output-format=github --show-info=false --threads=4
46 changes: 46 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
on:
- push

name: Run PHPUnit tests

jobs:
mutation:
name: PHP ${{ matrix.php }}-${{ matrix.os }}

runs-on: ${{ matrix.os }}

strategy:
matrix:
os:
- ubuntu-latest

php:
- "8.1"
- "8.2"

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
tools: composer:v2, cs2pr
coverage: none

- name: Determine composer cache directory
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV

- name: Cache dependencies installed with composer
uses: actions/cache@v3
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
php${{ matrix.php }}-composer-
- name: Install dependencies with composer
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi

- name: Run PHPUnit tests
run: vendor/bin/phpunit --colors=always
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
clover.xml
coveralls-upload.json
phpunit.xml
.phpcs-cache
.phpunit.result.cache

# Created by .ignore support plugin (hsz.mobi)
### JetBrains template
Expand Down Expand Up @@ -36,4 +37,4 @@ composer.phar

# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
composer.lock
composer.lock
2 changes: 1 addition & 1 deletion OSSMETADATA
Original file line number Diff line number Diff line change
@@ -1 +1 @@
osslifecycle=active
osslifecycle=active
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
DotKernel log component extending and customizing

![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-log)
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-log/3.2.0)



![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-log/3.4.0)

[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-log)](https://github.com/dotkernel/dot-log/issues)
[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-log)](https://github.com/dotkernel/dot-log/network)
[![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-log)](https://github.com/dotkernel/dot-log/stargazers)
[![GitHub license](https://img.shields.io/github/license/dotkernel/dot-log)](https://github.com/dotkernel/dot-log/blob/3.0/LICENSE.md)

[![SymfonyInsight](https://insight.symfony.com/projects/287e81e8-b4fb-4452-bd8f-4f12c0ab1f76/big.svg)](https://insight.symfony.com/projects/287e81e8-b4fb-4452-bd8f-4f12c0ab1f76)


## Adding The Config Provider
* Enter config/config.php
* If there is no entry for the config provider below, add it:
Expand Down
28 changes: 23 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@
}
],
"require": {
"php": "~7.4.0 || ~8.0.0 || ~8.1.0",
"php": "~8.1.0 || ~8.2.0",
"psr/http-message": "^1.0.1",
"laminas/laminas-servicemanager": "^3.10.0",
"laminas/laminas-log": "2.15.2"
"laminas/laminas-log": "2.15.2",
"dotkernel/dot-mail": "^3.0.0"
},
"require-dev": {
"phpunit/phpunit": "^9.1.2",
"squizlabs/php_codesniffer": "^3.5.5",
"dotkernel/dot-mail": "^3.0.0"
"phpunit/phpunit": "^10.2",
"laminas/laminas-coding-standard": "^2.5",
"vimeo/psalm": "^5.13"
},
"autoload": {
"psr-4": {
Expand All @@ -38,5 +39,22 @@
"psr-4": {
"DotTest\\Log\\": "test/"
}
},
"config": {
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"scripts": {
"check": [
"@cs-check",
"@test"
],
"cs-check": "phpcs",
"cs-fix": "phpcbf",
"test": "phpunit --colors=always",
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml",
"static-analysis": "psalm --shepherd --stats"
}
}
20 changes: 20 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">

<arg name="basepath" value="."/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>

<!-- Show progress -->
<arg value="p"/>

<!-- Paths to check -->
<file>src</file>
<file>test</file>

<!-- Include all rules from the Laminas Coding Standard -->
<rule ref="LaminasCodingStandard"/>
</ruleset>
12 changes: 12 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/|version|/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Dot Log Test Suite">
<directory>./test</directory>
</testsuite>
</testsuites>
</phpunit>
17 changes: 17 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<psalm
errorLevel="4"
resolveFromConfigFile="true"
findUnusedCode="false"
findUnusedBaselineEntry="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>
48 changes: 13 additions & 35 deletions src/ConfigProvider.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<?php
/**
* @see https://github.com/dotkernel/dot-log/ for the canonical source repository
* @copyright Copyright (c) 2017 Apidemia (https://www.apidemia.com)
* @license https://github.com/dotkernel/dot-log/blob/master/LICENSE.md MIT License
*/

declare(strict_types = 1);
declare(strict_types=1);

namespace Dot\Log;

Expand All @@ -21,58 +16,41 @@
use Laminas\Log\ProcessorPluginManager;
use Laminas\Log\WriterPluginManager;

/**
* Class ConfigProvider
* @package Dot\Log
*/
class ConfigProvider
{
/**
* @return array
*/
public function __invoke(): array
{
return [
'dependencies' => $this->getDependencies(),

'dot_log' => [

'dot_log' => [
'formatter_manager' => [],

'filter_manager' => [],

'filter_manager' => [],
'processor_manager' => [],

'writer_manager' => [],

'loggers' => [],

'writer_manager' => [],
'loggers' => [],
],
];
}

/**
* @return array
*/
public function getDependencies(): array
{
return [
'abstract_factories' => [
LoggerAbstractServiceFactory::class,
],
'aliases' => [
FilterPluginManager::class => 'LogFilterManager',
'aliases' => [
FilterPluginManager::class => 'LogFilterManager',
FormatterPluginManager::class => 'LogFormatterManager',
ProcessorPluginManager::class => 'LogProcessorManager',
WriterPluginManager::class => 'LogWriterManager',
WriterPluginManager::class => 'LogWriterManager',
],
'factories' => [
Logger::class => LoggerServiceFactory::class,
'LogFilterManager' => FilterPluginManagerFactory::class,
'factories' => [
Logger::class => LoggerServiceFactory::class,
'LogFilterManager' => FilterPluginManagerFactory::class,
'LogFormatterManager' => FormatterPluginManagerFactory::class,
'LogProcessorManager' => ProcessorPluginManagerFactory::class,
'LogWriterManager' => WriterPluginManagerFactory::class,
]
'LogWriterManager' => WriterPluginManagerFactory::class,
],
];
}
}
Loading

0 comments on commit 4c39fef

Please sign in to comment.