Prepare v1.0 release

rename template adapter to flasher, and add title to base notification class

Wip
This commit is contained in:
KHOUBZA Younes
2022-05-16 08:07:49 +01:00
parent cceaa9d814
commit ac6d046c63
689 changed files with 7328 additions and 15180 deletions
-2
View File
@@ -1,5 +1,3 @@
# These are supported funding model platforms
patreon: yoeunes
ko_fi: yoeunes
open_collective: php-flasher
+23 -134
View File
@@ -1,160 +1,49 @@
name: Running tests
name: tests
on:
push:
pull_request:
schedule:
- cron: '* * * * *'
jobs:
test:
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
laravel:
- 8.*
- 7.*
- 6.*
- 5.8.*
- 5.7.*
- 5.6.*
- 5.5.*
- 5.4.*
- 5.3.*
- 5.2.*
- 5.1.*
- 5.0.*
- 4.2.*
- 4.1.*
- 4.0.*
os:
- ubuntu-latest
# - macos-latest
# - windows-latest
laravel: [ 9.*, 8.*, 7.*, 6.*, 5.8.*, 5.7.*, 5.6.*, 5.5.*, 5.4.*, 5.3.*, 5.2.*, 5.1.*, 5.0.*, 4.2.*, 4.1.*, 4.0.* ]
include:
- laravel: 8.*
testbench: 6.*
php: 7.3
phpunit: 9.3.*
- { laravel: 9.*, testbench: 7.*, php: 8.0, phpunit: 9.5.* }
- { laravel: 8.*, testbench: 6.*, php: 7.3, phpunit: 9.3.* }
- { laravel: 7.*, testbench: 5.*, php: 7.3, phpunit: 8.4.* }
- { laravel: 6.*, testbench: 4.*, php: 7.2, phpunit: 8.3.* }
- { laravel: 5.8.*, testbench: 3.8.*, php: 7.1, phpunit: 7.5.* }
- { laravel: 5.7.*, testbench: 3.7.*, php: 7.1, phpunit: 7.0.* }
- { laravel: 5.6.*, testbench: 3.6.*, php: 7.1, phpunit: 7.0.* }
- { laravel: 5.5.*, testbench: 3.5.*, php: 7.0, phpunit: 6.0.* }
- { laravel: 5.4.*, testbench: 3.4.*, php: 5.6, phpunit: 5.7.* }
- { laravel: 5.3.*, testbench: 3.3.*, php: 5.6, phpunit: 4.8.* }
- { laravel: 5.2.*, testbench: 3.2.*, php: 5.5, phpunit: 4.8.* }
- { laravel: 5.1.*, testbench: 3.1.*, php: 5.5, phpunit: 4.8.* }
- { laravel: 5.0.*, testbench: 3.0.*, php: 5.4, phpunit: 4.8.* }
- { laravel: 4.2.*, testbench: 2.2.*, php: 5.4, phpunit: 4.8.* }
- { laravel: 4.1.*, testbench: 2.1.*, php: 5.4, phpunit: 4.8.* }
- { laravel: 4.0.*, testbench: 2.0.*, php: 5.4, phpunit: 4.8.* }
- laravel: 7.*
testbench: 5.*
php: 7.3
phpunit: 8.4.*
- laravel: 6.*
testbench: 4.*
php: 7.2
phpunit: 8.3.*
- laravel: 5.8.*
testbench: 3.8.*
php: 7.1
phpunit: 7.5.*
- laravel: 5.7.*
testbench: 3.7.*
php: 7.1
phpunit: 7.0.*
- laravel: 5.6.*
testbench: 3.6.*
php: 7.1
phpunit: 7.0.*
- laravel: 5.5.*
testbench: 3.5.*
php: 7.0
phpunit: 6.0.*
- laravel: 5.4.*
testbench: 3.4.*
php: 5.6
phpunit: 5.7.*
- laravel: 5.3.*
testbench: 3.3.*
php: 5.6
phpunit: 4.8.*
- laravel: 5.2.*
testbench: 3.2.*
php: 5.5
phpunit: 4.8.*
- laravel: 5.1.*
testbench: 3.1.*
php: 5.5
phpunit: 4.8.*
- laravel: 5.0.*
testbench: 3.0.*
php: 5.4
phpunit: 4.8.*
- laravel: 4.2.*
testbench: 2.2.*
php: 5.4
phpunit: 4.8.*
- laravel: 4.1.*
testbench: 2.1.*
php: 5.4
phpunit: 4.8.*
- laravel: 4.0.*
testbench: 2.0.*
php: 5.4
phpunit: 4.8.*
name: ${{ matrix.os }} - L${{ matrix.laravel }} - P${{ matrix.php }}
name: laravel[${{ matrix.laravel }}] php[${{ matrix.php }}]
steps:
- name: Checkout code
uses: actions/checkout@v1
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.composer/cache/files
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
ini-values: memory_limit=-1
coverage: none
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "phpunit/phpunit:${{ matrix.phpunit }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --prefer-dist --no-interaction --no-suggest
composer remove friendsofphp/php-cs-fixer laravel/laravel livewire/livewire phpstan/phpstan symfony/symfony orchestra/testbench phpunit/phpunit --dev
composer require "laravel/framework:${{ matrix.laravel }}" "phpunit/phpunit:${{ matrix.phpunit }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction
- name: Execute tests
run: vendor/bin/phpunit --configuration=phpunit-laravel.xml
- name: Install Flasher Depencies
run: |
composer require "php-flasher/flasher:^0.9"
composer require "php-flasher/flasher-laravel:^0.9"
composer require "php-flasher/flasher-cli:^0.9"
composer require "php-flasher/flasher-cli-laravel:^0.9"
composer require "php-flasher/flasher-toastr:^0.9"
composer require "php-flasher/flasher-toastr-laravel:^0.9"
composer require "php-flasher/flasher-noty:^0.9"
composer require "php-flasher/flasher-noty-laravel:^0.9"
composer require "php-flasher/flasher-notyf:^0.9"
composer require "php-flasher/flasher-notyf-laravel:^0.9"
composer require "php-flasher/flasher-sweet-alert:^0.9"
composer require "php-flasher/flasher-sweet-alert-laravel:^0.9"
composer require "php-flasher/flasher-pnotify:^0.9"
composer require "php-flasher/flasher-pnotify-laravel:^0.9"
+78
View File
@@ -0,0 +1,78 @@
name: Split Monorepo
on:
push:
branches:
- main
tags:
- '*'
jobs:
split_monorepo:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package:
- { path: 'src/Prime', repo: 'flasher' }
- { path: 'src/Laravel', repo: 'flasher-laravel' }
- { path: 'src/Symfony', repo: 'flasher-symfony' }
- { path: 'src/Cli/Prime', repo: 'flasher-cli' }
- { path: 'src/Cli/Laravel', repo: 'flasher-cli-laravel' }
- { path: 'src/Cli/Symfony', repo: 'flasher-cli-symfony' }
- { path: 'src/Noty/Prime', repo: 'flasher-noty' }
- { path: 'src/Noty/Laravel', repo: 'flasher-noty-laravel' }
- { path: 'src/Noty/Symfony', repo: 'flasher-noty-symfony' }
- { path: 'src/Notyf/Prime', repo: 'flasher-notyf' }
- { path: 'src/Notyf/Laravel', repo: 'flasher-notyf-laravel' }
- { path: 'src/Notyf/Symfony', repo: 'flasher-notyf-symfony' }
- { path: 'src/Pnotify/Prime', repo: 'flasher-pnotify' }
- { path: 'src/Pnotify/Laravel', repo: 'flasher-pnotify-laravel' }
- { path: 'src/Pnotify/Symfony', repo: 'flasher-pnotify-symfony' }
- { path: 'src/SweetAlert/Prime', repo: 'flasher-sweetalert' }
- { path: 'src/SweetAlert/Laravel', repo: 'flasher-sweetalert-laravel' }
- { path: 'src/SweetAlert/Symfony', repo: 'flasher-sweetalert-symfony' }
- { path: 'src/Toastr/Prime', repo: 'flasher-toastr' }
- { path: 'src/Toastr/Laravel', repo: 'flasher-toastr-laravel' }
- { path: 'src/Toastr/Symfony', repo: 'flasher-toastr-symfony' }
- { path: 'packs/php-pack', repo: 'php-pack' }
- { path: 'packs/laravel-pack', repo: 'laravel-pack' }
- { path: 'packs/symfony-pack', repo: 'symfony-pack' }
steps:
- uses: actions/checkout@v2
- if: "!startsWith(github.ref, 'refs/tags/')"
name: Monorepo Split of ${{ matrix.package }}
uses: symplify/github-action-monorepo-split@2.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
package-directory: '${{ matrix.package.path }}'
split-repository-organization: 'php-flasher'
split-repository-name: '${{ matrix.package.repo }}'
user-name: "Younes KHOUBZA"
user-email: "younes.khoubza@gmail.com"
branch: main
- if: "startsWith(github.ref, 'refs/tags/')"
name: Monorepo Tagged Split of ${{ matrix.package }}
uses: symplify/github-action-monorepo-split@2.0
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
with:
tag: ${GITHUB_REF#refs/tags/}
package-directory: 'src/${{ matrix.package.path }}'
split-repository-organization: 'php-flasher'
split-repository-name: '${{ matrix.package.repo }}'
user-name: "Younes KHOUBZA"
user-email: "younes.khoubza@gmail.com"
branch: main
+32 -164
View File
@@ -1,191 +1,59 @@
name: Running tests
name: tests
on:
push:
pull_request:
schedule:
- cron: '* * * * *'
jobs:
test:
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
symfony:
- 5.4.*
- 5.3.*
- 5.2.*
- 5.1.*
- 5.0.*
- 4.4.*
- 4.3.*
- 4.2.*
- 4.1.*
- 4.0.*
- 3.4.*
- 3.3.*
- 3.2.*
- 3.1.*
- 3.0.*
- 2.8.*
- 2.7.*
- 2.6.*
- 2.5.*
- 2.4.*
- 2.3.*
- 2.2.*
- 2.1.*
- 2.0.*
os:
- ubuntu-latest
# - macos-latest
# - windows-latest
symfony: [ 6.0.*, 5.4.*, 5.3.*, 5.2.*, 5.1.*, 5.0.*, 4.4.*, 4.3.*, 4.2.*, 4.1.*, 4.0.*, 3.4.*, 3.3.*, 3.2.*, 3.1.*, 3.0.*, 2.8.*, 2.7.*, 2.6.*, 2.5.*, 2.4.*, 2.3.*, 2.2.*, 2.1.*, 2.0.* ]
include:
- symfony: 5.4.*
php: 7.2
phpunit: 8.3.*
- { symfony: 6.0.*, php: 8.0, phpunit: 9.5.* }
- { symfony: 5.4.*, php: 7.2, phpunit: 8.3.* }
- { symfony: 5.3.*, php: 7.2, phpunit: 8.3.* }
- { symfony: 5.2.*, php: 7.2, phpunit: 8.3.* }
- { symfony: 5.1.*, php: 7.2, phpunit: 8.3.* }
- { symfony: 5.0.*, php: 7.2, phpunit: 8.3.* }
- { symfony: 4.4.*, php: 7.1, phpunit: 7.0.* }
- { symfony: 4.3.*, php: 7.1, phpunit: 7.0.* }
- { symfony: 4.2.*, php: 7.1, phpunit: 7.0.* }
- { symfony: 4.1.*, php: 7.1, phpunit: 7.0.* }
- { symfony: 4.0.*, php: 7.1, phpunit: 7.0.* }
- { symfony: 3.4.*, php: 5.5, phpunit: 4.8.36 }
- { symfony: 3.3.*, php: 5.5, phpunit: 4.8.36 }
- { symfony: 3.2.*, php: 5.5, phpunit: 4.8.36 }
- { symfony: 3.1.*, php: 5.5, phpunit: 4.8.36 }
- { symfony: 3.0.*, php: 5.5, phpunit: 4.8.36 }
- { symfony: 2.8.*, php: 5.3, phpunit: 4.8.36 }
- { symfony: 2.7.*, php: 5.3, phpunit: 4.8.36 }
- { symfony: 2.6.*, php: 5.3, phpunit: 4.8.36 }
- { symfony: 2.5.*, php: 5.3, phpunit: 4.8.36 }
- { symfony: 2.4.*, php: 5.3, phpunit: 4.8.36 }
- { symfony: 2.3.*, php: 5.3, phpunit: 4.8.36 }
- { symfony: 2.2.*, php: 5.3, phpunit: 4.8.36 }
- { symfony: 2.1.*, php: 5.3, phpunit: 4.8.36 }
- { symfony: 2.0.*, php: 5.3, phpunit: 4.8.36 }
- symfony: 5.3.*
php: 7.2
phpunit: 8.3.*
- symfony: 5.2.*
php: 7.2
phpunit: 8.3.*
- symfony: 5.1.*
php: 7.2
phpunit: 8.3.*
- symfony: 5.0.*
php: 7.2
phpunit: 8.3.*
- symfony: 4.4.*
php: 7.1
phpunit: 7.0.*
- symfony: 4.3.*
php: 7.1
phpunit: 7.0.*
- symfony: 4.2.*
php: 7.1
phpunit: 7.0.*
- symfony: 4.1.*
php: 7.1
phpunit: 7.0.*
- symfony: 4.0.*
php: 7.1
phpunit: 7.0.*
- symfony: 3.4.*
php: 5.5
phpunit: 4.8.36
- symfony: 3.3.*
php: 5.5
phpunit: 4.8.36
- symfony: 3.2.*
php: 5.5
phpunit: 4.8.36
- symfony: 3.1.*
php: 5.5
phpunit: 4.8.36
- symfony: 3.0.*
php: 5.5
phpunit: 4.8.36
- symfony: 2.8.*
php: 5.3
phpunit: 4.8.36
- symfony: 2.7.*
php: 5.3
phpunit: 4.8.36
- symfony: 2.6.*
php: 5.3
phpunit: 4.8.36
- symfony: 2.5.*
php: 5.3
phpunit: 4.8.36
- symfony: 2.4.*
php: 5.3
phpunit: 4.8.36
- symfony: 2.3.*
php: 5.3
phpunit: 4.8.36
- symfony: 2.2.*
php: 5.3
phpunit: 4.8.36
- symfony: 2.1.*
php: 5.3
phpunit: 4.8.36
- symfony: 2.0.*
php: 5.3
phpunit: 4.8.36
name: ${{ matrix.os }} - S${{ matrix.symfony }} - P${{ matrix.php }}
name: symfony[${{ matrix.symfony }}] php[${{ matrix.php }}]
steps:
- name: Checkout code
uses: actions/checkout@v1
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.composer/cache/files
key: dependencies-symfony-${{ matrix.symfony }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
coverage: none
- name: Install dependencies
run: |
composer require "symfony/symfony:${{ matrix.symfony }}" "phpunit/phpunit:${{ matrix.phpunit }}" twig/twig --no-interaction --no-update
composer remove friendsofphp/php-cs-fixer laravel/laravel livewire/livewire phpstan/phpstan symfony/symfony orchestra/testbench phpunit/phpunit --dev
composer config extra.symfony.require "${{ matrix.symfony }}"
composer update --prefer-dist --no-interaction --no-suggest
composer require "symfony/symfony:${{ matrix.symfony }}" "phpunit/phpunit:${{ matrix.phpunit }}" --no-interaction
- name: Execute tests
run: vendor/bin/phpunit --configuration=phpunit-symfony.xml
- name: Install Flasher Depencies
run: |
composer require "php-flasher/flasher:^0.9"
composer require "php-flasher/flasher-laravel:^0.9"
composer require "php-flasher/flasher-symfony:^0.9"
composer require "php-flasher/flasher-cli:^0.9"
composer require "php-flasher/flasher-cli-symfony:^0.9"
composer require "php-flasher/flasher-toastr:^0.9"
composer require "php-flasher/flasher-toastr-symfony:^0.9"
composer require "php-flasher/flasher-noty:^0.9"
composer require "php-flasher/flasher-noty-symfony:^0.9"
composer require "php-flasher/flasher-notyf:^0.9"
composer require "php-flasher/flasher-notyf-symfony:^0.9"
composer require "php-flasher/flasher-sweet-alert:^0.9"
composer require "php-flasher/flasher-sweet-alert-symfony:^0.9"
composer require "php-flasher/flasher-pnotify:^0.9"
composer require "php-flasher/flasher-pnotify-symfony:^0.9"
+4
View File
@@ -3,3 +3,7 @@ vendor
composer.lock
.phpunit.result.cache
.phpcs-cache
.php-cs-fixer.cache
packs/**/composer.lock
packs/**/vendor/
+66
View File
@@ -0,0 +1,66 @@
<?php
/*
* This file is part of the PHPFlasher package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
if (!file_exists(__DIR__.'/src')) {
exit(0);
}
$header = <<<'EOF'
This file is part of the PHPFlasher package.
(c) Younes KHOUBZA <younes.khoubza@gmail.com>
EOF;
$rules = array(
'@PSR12' => true,
'@PSR12:risky' => true,
'@Symfony' => true,
'@Symfony:risky' => true,
'@PhpCsFixer' => true,
'@PhpCsFixer:risky' => true,
'header_comment' => array('header' => $header),
'array_syntax' => array('syntax' => 'long'),
'ordered_imports' => array(
'sort_algorithm' => 'alpha',
'imports_order' => array('const', 'class', 'function'),
),
'no_extra_blank_lines' => array(
'tokens' => array('case', 'continue', 'curly_brace_block', 'default', 'extra', 'parenthesis_brace_block', 'square_brace_block', 'switch', 'throw'),
),
'function_to_constant' => false,
'visibility_required' => array('elements' => array('property', 'method')),
'self_accessor' => false,
'single_trait_insert_per_statement' => true,
'linebreak_after_opening_tag' => true,
'no_php4_constructor' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'phpdoc_order' => true,
'strict_comparison' => true,
'strict_param' => true,
'phpdoc_line_span' => true,
'php_unit_internal_class' => false,
'php_unit_test_class_requires_covers' => false,
'multiline_whitespace_before_semicolons' => false,
'method_chaining_indentation' => false,
'phpdoc_no_empty_return' => false,
'phpdoc_types_order' => array('null_adjustment' => 'always_last'),
'php_unit_test_case_static_method_calls' => array('call_type' => 'this'),
'php_unit_strict' => false,
'native_constant_invocation' => array('scope' => 'namespaced'),
'phpdoc_return_self_reference' => true,
);
$finder = new PhpCsFixer\Finder();
$finder->in(__DIR__)->exclude(__DIR__.'/vendor');
$config = new PhpCsFixer\Config();
return $config->setFinder($finder)
->setUsingCache(false)
->setRiskyAllowed(true)
->setRules($rules);
+22
View File
@@ -0,0 +1,22 @@
name: Auto Closer PR
on:
pull_request_target:
types: [opened]
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: superbrothers/close-pull-request@v3
with:
comment: |
Hi, thank you for your contribution.
Unfortunately, this repository is read-only. It's a split from our main monorepo repository.
We'd like to kindly ask you to move the contribution there - https://github.com/php-flasher/php-flasher.
We'll check it, review it and give you feed back right way.
Thank you.
+4
View File
@@ -0,0 +1,4 @@
include make/variables.mk
include make/help.mk
include make/composer.mk
include make/lint.mk
+1 -21
View File
@@ -24,12 +24,6 @@
<a href="https://packagist.org/packages/php-flasher/flasher">
<img src="https://img.shields.io/packagist/php-v/php-flasher/flasher.svg?style=flat-square">
</a>
<a href="https://opencollective.com/php-flasher">
<img src="https://opencollective.com/php-flasher/tiers/backer/badge.svg?label=backer&color=brightgreen" />
</a>
<a href="https://opencollective.com/php-flasher">
<img src="https://opencollective.com/php-flasher/tiers/sponsor/badge.svg?label=sponsor&color=brightgreen" />
</a>
</p>
# Why use PHP Flasher ?
@@ -53,21 +47,7 @@ This library is designed, so you can take full control when creating you notific
## Official Documentation
Documentation for PHP Flasher can be found on the [PHP Flasher website](https://php-flasher.github.io/).
## Backers && Sponsors
Support this project by becoming a sponsor. Your name will show up in the Contribute page of all PHP Flasher installations as well as here with a link to your website!
Thank you to all our backers and sponsors! 🙏
<a href="https://opencollective.com/php-flasher#backers" target="_blank">
<img src="https://opencollective.com/php-flasher/backers.svg?width=890" title="Backers" alt="Backers">
</a>
<a href="https://opencollective.com/php-flasher#sponsors" target="_blank">
<img src="https://opencollective.com/php-flasher/sponsors.svg?width=890" title="Sponsors" alt="Sponsors">
</a>
Documentation for PHP Flasher can be found on the [PHP Flasher website](https://php-flasher.io).
### Contact
Executable
+53
View File
@@ -0,0 +1,53 @@
#!/usr/bin/env php
<?php
$shared = realpath(__DIR__.'/../.shared');
$resources = array(
$shared,
// __DIR__.'/../.github/ISSUE_TEMPLATE/',
__DIR__.'/../.github/FUNDING.yml',
__DIR__.'/../README.md',
__DIR__.'/../LICENSE',
);
$dirs = array(__DIR__.'/../packs', __DIR__.'/../src');
$packages = array();
foreach ($dirs as $dir) {
$packages = array_merge($packages, glob($dir.'/*/composer.json'));
$packages = array_merge($packages, glob($dir.'/*/*/composer.json'));
}
foreach ($packages as $package) {
$package = realpath(dirname($package));
foreach ($resources as $resource) {
$resource = realpath($resource);
$dest = $package.str_replace(realpath(__DIR__.'/../'), '', $resource);
if (!is_dir($resource) && file_exists($resource)) {
copy($resource, $dest);
continue;
}
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($resource, FilesystemIterator::SKIP_DOTS),
RecursiveIteratorIterator::SELF_FIRST
);
foreach ($files as $file) {
$target = $resource === $shared
? $package.str_replace($resource, '', $file->getPathname())
: $dest .'/'. $file->getFilename();
if ($file->isDir()) {
system('rm -rf -- ' . escapeshellarg($dest));
@mkdir(dirname($target), 0777, true);
continue;
}
@mkdir(dirname($target), 0777, true);
@copy($file->getPathname(), $target);
}
}
}
-83
View File
@@ -1,83 +0,0 @@
#!/usr/bin/env bash
set -e
# Make sure the release tag is provided.
if (( "$#" != 1 ))
then
echo "Tag has to be provided."
exit 1
fi
RELEASE_BRANCH="main"
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
VERSION=$1
# Make sure current branch and release branch match.
if [[ "$RELEASE_BRANCH" != "$CURRENT_BRANCH" ]]
then
echo "Release branch ($RELEASE_BRANCH) does not match the current active branch ($CURRENT_BRANCH)."
exit 1
fi
# Make sure the working directory is clear.
if [[ ! -z "$(git status --porcelain)" ]]
then
echo "Your working directory is dirty. Did you forget to commit your changes?"
exit 1
fi
# Make sure latest changes are fetched first.
git fetch origin
# Make sure that release branch is in sync with origin.
if [[ $(git rev-parse HEAD) != $(git rev-parse origin/$RELEASE_BRANCH) ]]
then
echo "Your branch is out of date with its upstream. Did you forget to pull or push any changes before releasing?"
exit 1
fi
# Always prepend with "v"
if [[ $VERSION != v* ]]
then
VERSION="v$VERSION"
fi
# Tag PHP Flasher
git tag "$VERSION"
git push origin --tags --force
# Tag Repositories
for REMOTE in flasher flasher-laravel flasher-symfony flasher-livewire \
flasher-toastr flasher-toastr-laravel flasher-toastr-symfony \
flasher-notyf flasher-notyf-laravel flasher-notyf-symfony \
flasher-sweet-alert flasher-sweet-alert-laravel flasher-sweet-alert-symfony \
flasher-pnotify flasher-pnotify-laravel flasher-pnotify-symfony \
flasher-noty flasher-noty-laravel flasher-noty-symfony \
flasher-cli flasher-cli-laravel flasher-cli-symfony \
laravel-pack livewire-pack php-pack symfony-pack
do
echo ""
echo ""
echo "Releasing $REMOTE";
TMP_DIR="/tmp/php-flasher"
REMOTE_URL="git@github.com:php-flasher/$REMOTE.git"
rm -rf $TMP_DIR;
mkdir $TMP_DIR;
(
cd $TMP_DIR;
git clone $REMOTE_URL .
git checkout "$RELEASE_BRANCH";
git tag "$VERSION"
git push origin --tags
)
done
-84
View File
@@ -1,84 +0,0 @@
#!/usr/bin/env bash
set -e
set -x
CURRENT_BRANCH="main"
function split()
{
# git merge --strategy recursive --strategy-option subtree="$1" "$2/$CURRENT_BRANCH" --allow-unrelated-histories -m "Merge remote-tracking branch '$2/$CURRENT_BRANCH'"
SHA1=$(./bin/splitsh-lite --prefix="$1")
git push $2 "$SHA1:refs/heads/$CURRENT_BRANCH" -f
}
function remote()
{
git remote add "$1" "$2" || true
}
git pull origin $CURRENT_BRANCH
remote flasher git@github.com:php-flasher/flasher.git
remote laravel git@github.com:php-flasher/flasher-laravel.git
remote symfony git@github.com:php-flasher/flasher-symfony.git
remote livewire git@github.com:php-flasher/flasher-livewire.git
remote toastr git@github.com:php-flasher/flasher-toastr.git
remote toastr-laravel git@github.com:php-flasher/flasher-toastr-laravel.git
remote toastr-symfony git@github.com:php-flasher/flasher-toastr-symfony.git
remote notyf git@github.com:php-flasher/flasher-notyf.git
remote notyf-laravel git@github.com:php-flasher/flasher-notyf-laravel.git
remote notyf-symfony git@github.com:php-flasher/flasher-notyf-symfony.git
remote sweet-alert git@github.com:php-flasher/flasher-sweet-alert.git
remote sweet-alert-laravel git@github.com:php-flasher/flasher-sweet-alert-laravel.git
remote sweet-alert-symfony git@github.com:php-flasher/flasher-sweet-alert-symfony.git
remote pnotify git@github.com:php-flasher/flasher-pnotify.git
remote pnotify-laravel git@github.com:php-flasher/flasher-pnotify-laravel.git
remote pnotify-symfony git@github.com:php-flasher/flasher-pnotify-symfony.git
remote noty git@github.com:php-flasher/flasher-noty.git
remote noty-laravel git@github.com:php-flasher/flasher-noty-laravel.git
remote noty-symfony git@github.com:php-flasher/flasher-noty-symfony.git
remote cli git@github.com:php-flasher/flasher-cli.git
remote cli-laravel git@github.com:php-flasher/flasher-cli-laravel.git
remote cli-symfony git@github.com:php-flasher/flasher-cli-symfony.git
remote laravel-pack git@github.com:php-flasher/laravel-pack.git
remote livewire-pack git@github.com:php-flasher/livewire-pack.git
remote php-pack git@github.com:php-flasher/php-pack.git
remote symfony-pack git@github.com:php-flasher/symfony-pack.git
split 'src/Prime' flasher
split 'src/Laravel' laravel
split 'src/Symfony' symfony
split 'src/Livewire' livewire
split 'src/Toastr/Prime' toastr
split 'src/Toastr/Laravel' toastr-laravel
split 'src/Toastr/Symfony' toastr-symfony
split 'src/Notyf/Prime' notyf
split 'src/Notyf/Laravel' notyf-laravel
split 'src/Notyf/Symfony' notyf-symfony
split 'src/SweetAlert/Prime' sweet-alert
split 'src/SweetAlert/Laravel' sweet-alert-laravel
split 'src/SweetAlert/Symfony' sweet-alert-symfony
split 'src/Pnotify/Prime' pnotify
split 'src/Pnotify/Laravel' pnotify-laravel
split 'src/Pnotify/Symfony' pnotify-symfony
split 'src/Noty/Prime' noty
split 'src/Noty/Laravel' noty-laravel
split 'src/Noty/Symfony' noty-symfony
split 'packs/laravel-pack' laravel-pack
split 'packs/livewire-pack' livewire-pack
split 'packs/php-pack' php-pack
split 'packs/symfony-pack' symfony-pack
BIN
View File
Binary file not shown.
Executable → Regular
+93 -16
View File
@@ -1,13 +1,13 @@
{
"name": "php-flasher/php-flasher",
"description": "All flasher components in one place for easy maintenance with splitsh",
"description": "Repository for PHPFlasher development",
"type": "project",
"license": "MIT",
"authors": [
{
"name": "KHOUBZA Younes",
"name": "Younes KHOUBZA",
"email": "younes.khoubza@gmail.com",
"homepage": "https://github.com/yoeunes",
"homepage": "https://www.linkedin.com/in/younes-khoubza",
"role": "Developer"
}
],
@@ -16,25 +16,102 @@
"ext-json": "*",
"ext-mbstring": "*"
},
"autoload": {
"psr-4": {
"Flasher\\": "src/"
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.8",
"laravel/laravel": "^9.1",
"livewire/livewire": "^2.10",
"orchestra/testbench": "^7.5",
"phpstan/phpstan": "^1.6",
"phpunit/phpunit": "^9.5",
"symfony/symfony": "^6.0"
},
"autoload": {
"files": [
"src/Prime/helpers.php",
"src/Laravel/helpers.php",
"src/Toastr/Laravel/Resources/functions/toastr.php",
"src/Noty/Laravel/Resources/functions/noty.php",
"src/Notyf/Laravel/Resources/functions/notyf.php",
"src/Pnotify/Laravel/Resources/functions/pnotify.php",
"src/SweetAlert/Laravel/Resources/functions/sweetAlert.php",
"src/Cli/Laravel/Resources/functions/cli.php"
]
"src/Cli/Laravel/notify.php",
"src/Laravel/flasher.php",
"src/Noty/Laravel/noty.php",
"src/Notyf/Laravel/notyf.php",
"src/Pnotify/Laravel/pnotify.php",
"src/SweetAlert/Laravel/sweetalert.php",
"src/Toastr/Laravel/toastr.php"
],
"psr-4": {
"Flasher\\": "src/",
"Flasher\\Cli\\Laravel\\": "src/Cli/Laravel/",
"Flasher\\Cli\\Prime\\": "src/Cli/Prime/",
"Flasher\\Cli\\Symfony\\": "src/Cli/Symfony/",
"Flasher\\Laravel\\": "src/Laravel/",
"Flasher\\Noty\\Laravel\\": "src/Noty/Laravel/",
"Flasher\\Noty\\Prime\\": "src/Noty/Prime/",
"Flasher\\Noty\\Symfony\\": "src/Noty/Symfony/",
"Flasher\\Notyf\\Laravel\\": "src/Notyf/Laravel/",
"Flasher\\Notyf\\Prime\\": "src/Notyf/Prime/",
"Flasher\\Notyf\\Symfony\\": "src/Notyf/Symfony/",
"Flasher\\Pnotify\\Laravel\\": "src/Pnotify/Laravel/",
"Flasher\\Pnotify\\Prime\\": "src/Pnotify/Prime/",
"Flasher\\Pnotify\\Symfony\\": "src/Pnotify/Symfony/",
"Flasher\\Prime\\": "src/Prime/",
"Flasher\\SweetAlert\\Laravel\\": "src/SweetAlert/Laravel/",
"Flasher\\SweetAlert\\Prime\\": "src/SweetAlert/Prime/",
"Flasher\\SweetAlert\\Symfony\\": "src/SweetAlert/Symfony/",
"Flasher\\Symfony\\": "src/Symfony/",
"Flasher\\Toastr\\Laravel\\": "src/Toastr/Laravel/",
"Flasher\\Toastr\\Prime\\": "src/Toastr/Prime/",
"Flasher\\Toastr\\Symfony\\": "src/Toastr/Symfony/"
}
},
"autoload-dev": {
"psr-4": {
"Flasher\\Tests\\": "tests/"
}
},
"minimum-stability": "dev"
"extra": {
"laravel": {
"providers": [
"Flasher\\Cli\\Laravel\\FlasherCliServiceProvider",
"Flasher\\Toastr\\Laravel\\FlasherToastrServiceProvider",
"Flasher\\Laravel\\FlasherServiceProvider",
"Flasher\\Noty\\Laravel\\FlasherNotyServiceProvider",
"Flasher\\Pnotify\\Laravel\\FlasherPnotifyServiceProvider",
"Flasher\\Notyf\\Laravel\\FlasherNotyfServiceProvider",
"Flasher\\SweetAlert\\Laravel\\FlasherSweetAlertServiceProvider"
],
"aliases": {
"Toastr": "Flasher\\Toastr\\Laravel\\Facade\\Toastr",
"Flasher": "Flasher\\Laravel\\Facade\\Flasher",
"Noty": "Flasher\\Laravel\\Facade\\Flasher",
"Pnotify": "Flasher\\Pnotify\\Laravel\\Facade\\Pnotify",
"Notyf": "Flasher\\Notyf\\Laravel\\Facade\\Notyf",
"SweetAlert": "Flasher\\SweetAlert\\Laravel\\Facade\\SweetAlert"
}
}
},
"replace": {
"php-flasher/flasher": "self.version",
"php-flasher/flasher-cli": "self.version",
"php-flasher/flasher-cli-laravel": "self.version",
"php-flasher/flasher-cli-symfony": "self.version",
"php-flasher/flasher-laravel": "self.version",
"php-flasher/flasher-noty": "self.version",
"php-flasher/flasher-noty-laravel": "self.version",
"php-flasher/flasher-noty-symfony": "self.version",
"php-flasher/flasher-notyf": "self.version",
"php-flasher/flasher-notyf-laravel": "self.version",
"php-flasher/flasher-notyf-symfony": "self.version",
"php-flasher/flasher-pnotify": "self.version",
"php-flasher/flasher-pnotify-laravel": "self.version",
"php-flasher/flasher-pnotify-symfony": "self.version",
"php-flasher/flasher-sweetalert": "self.version",
"php-flasher/flasher-sweetalert-laravel": "self.version",
"php-flasher/flasher-sweetalert-symfony": "self.version",
"php-flasher/flasher-symfony": "self.version",
"php-flasher/flasher-toastr": "self.version",
"php-flasher/flasher-toastr-laravel": "self.version",
"php-flasher/flasher-toastr-symfony": "self.version"
},
"config": {
"sort-packages": true
},
"minimum-stability": "stable",
"prefer-stable": true
}
+9
View File
@@ -0,0 +1,9 @@
.PHONY: install update
## 🧙‍ Installs the project dependencies and assets
install: composer.lock
$(COMPOSER) install $(COMPOSER_ARGS)
## Upgrades your dependencies to the latest version according to composer.json, and updates the composer.lock file.
update:
$(COMPOSER) update --lock $(COMPOSER_ARGS)
+27
View File
@@ -0,0 +1,27 @@
.PHONY: help
COLOR_RESET = \033[0m
COLOR_INFO = \033[32m
COLOR_COMMENT = \033[33m
## Help
help:
@printf "${COLOR_COMMENT}Usage:${COLOR_RESET}\n"
@printf " make [target]\n\n"
@printf "${COLOR_COMMENT}Available targets:${COLOR_RESET}\n"
@awk '/^[a-zA-Z\-\_0-9\.@]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf " ${COLOR_INFO}%-16s${COLOR_RESET} %s\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
check_defined = \
$(strip $(foreach 1,$1, \
$(call __check_defined,$1,$(strip $(value 2)))))
__check_defined = \
$(if $(value $1),, \
$(error Undefined $1$(if $2, ($2))))
+11
View File
@@ -0,0 +1,11 @@
.PHONY: lint fix
## Run code style, linters
lint:
test `find ./src -iname "*.php" | xargs -n1 -P6 php -l | grep -Fv "No syntax errors" | wc -l` -eq 0
$(PHP_CS_FIXER) fix --diff --dry-run -v
$(COMPOSER) validate --strict
## Fix files with php-cs-fixer
fix:
$(PHP_CS_FIXER) fix --allow-risky=yes
+12
View File
@@ -0,0 +1,12 @@
# Executables
EXEC_PHP = php
COMPOSER = composer
# Parameters
COMPOSER_ARGS ?=
# Executables: vendors
PHP_CS_FIXER = ./vendor/bin/php-cs-fixer
# Misc
.DEFAULT_GOAL = help
+36
View File
@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
/*
* This file is part of the PHPFlasher package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\MonorepoBuilder\Release\ReleaseWorker\AddTagToChangelogReleaseWorker;
use Symplify\MonorepoBuilder\Release\ReleaseWorker\PushNextDevReleaseWorker;
use Symplify\MonorepoBuilder\Release\ReleaseWorker\PushTagReleaseWorker;
use Symplify\MonorepoBuilder\Release\ReleaseWorker\SetCurrentMutualDependenciesReleaseWorker;
use Symplify\MonorepoBuilder\Release\ReleaseWorker\SetNextMutualDependenciesReleaseWorker;
use Symplify\MonorepoBuilder\Release\ReleaseWorker\TagVersionReleaseWorker;
use Symplify\MonorepoBuilder\Release\ReleaseWorker\UpdateBranchAliasReleaseWorker;
use Symplify\MonorepoBuilder\Release\ReleaseWorker\UpdateReplaceReleaseWorker;
use Symplify\MonorepoBuilder\ValueObject\Option;
return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::PACKAGE_DIRECTORIES, array(
__DIR__.'/src',
));
$services = $containerConfigurator->services();
$services->set(UpdateReplaceReleaseWorker::class);
$services->set(SetCurrentMutualDependenciesReleaseWorker::class);
$services->set(AddTagToChangelogReleaseWorker::class);
$services->set(TagVersionReleaseWorker::class);
$services->set(PushTagReleaseWorker::class);
$services->set(SetNextMutualDependenciesReleaseWorker::class);
$services->set(UpdateBranchAliasReleaseWorker::class);
$services->set(PushNextDevReleaseWorker::class);
};
@@ -1,5 +1,3 @@
# These are supported funding model platforms
patreon: yoeunes
ko_fi: yoeunes
open_collective: php-flasher
+22
View File
@@ -0,0 +1,22 @@
name: Auto Closer PR
on:
pull_request_target:
types: [opened]
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: superbrothers/close-pull-request@v3
with:
comment: |
Hi, thank you for your contribution.
Unfortunately, this repository is read-only. It's a split from our main monorepo repository.
We'd like to kindly ask you to move the contribution there - https://github.com/php-flasher/php-flasher.
We'll check it, review it and give you feed back right way.
Thank you.
@@ -24,12 +24,6 @@
<a href="https://packagist.org/packages/php-flasher/flasher">
<img src="https://img.shields.io/packagist/php-v/php-flasher/flasher.svg?style=flat-square">
</a>
<a href="https://opencollective.com/php-flasher">
<img src="https://opencollective.com/php-flasher/tiers/backer/badge.svg?label=backer&color=brightgreen" />
</a>
<a href="https://opencollective.com/php-flasher">
<img src="https://opencollective.com/php-flasher/tiers/sponsor/badge.svg?label=sponsor&color=brightgreen" />
</a>
</p>
# Why use PHP Flasher ?
@@ -53,21 +47,7 @@ This library is designed, so you can take full control when creating you notific
## Official Documentation
Documentation for PHP Flasher can be found on the [PHP Flasher website](https://php-flasher.github.io/).
## Backers && Sponsors
Support this project by becoming a sponsor. Your name will show up in the Contribute page of all PHP Flasher installations as well as here with a link to your website!
Thank you to all our backers and sponsors! 🙏
<a href="https://opencollective.com/php-flasher#backers" target="_blank">
<img src="https://opencollective.com/php-flasher/backers.svg?width=890" title="Backers" alt="Backers">
</a>
<a href="https://opencollective.com/php-flasher#sponsors" target="_blank">
<img src="https://opencollective.com/php-flasher/sponsors.svg?width=890" title="Sponsors" alt="Sponsors">
</a>
Documentation for PHP Flasher can be found on the [PHP Flasher website](https://php-flasher.io).
### Contact
+3 -3
View File
@@ -5,9 +5,9 @@
"license": "MIT",
"authors": [
{
"name": "KHOUBZA Younes",
"name": "Younes KHOUBZA",
"email": "younes.khoubza@gmail.com",
"homepage": "https://github.com/yoeunes",
"homepage": "https://www.linkedin.com/in/younes-khoubza",
"role": "Developer"
}
],
@@ -16,7 +16,7 @@
"php-flasher/flasher-noty-laravel": "*",
"php-flasher/flasher-notyf-laravel": "*",
"php-flasher/flasher-pnotify-laravel": "*",
"php-flasher/flasher-sweet-alert-laravel": "*",
"php-flasher/flasher-sweetalert-laravel": "*",
"php-flasher/flasher-toastr-laravel": "*"
}
}
-21
View File
@@ -1,21 +0,0 @@
MIT License
Copyright (c) 2020 PHP Flasher
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-18
View File
@@ -1,18 +0,0 @@
{
"name": "php-flasher/livewire-pack",
"description": "A pack for Livewire",
"type": "flasher-pack",
"license": "MIT",
"authors": [
{
"name": "KHOUBZA Younes",
"email": "younes.khoubza@gmail.com",
"homepage": "https://github.com/yoeunes",
"role": "Developer"
}
],
"require": {
"php-flasher/laravel-pack": "*",
"php-flasher/flasher-livewire": "*"
}
}
+4
View File
@@ -0,0 +1,4 @@
patreon: yoeunes
ko_fi: yoeunes
open_collective: php-flasher
custom: ['https://www.paypal.com/paypalme/yoeunes']
+22
View File
@@ -0,0 +1,22 @@
name: Auto Closer PR
on:
pull_request_target:
types: [opened]
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: superbrothers/close-pull-request@v3
with:
comment: |
Hi, thank you for your contribution.
Unfortunately, this repository is read-only. It's a split from our main monorepo repository.
We'd like to kindly ask you to move the contribution there - https://github.com/php-flasher/php-flasher.
We'll check it, review it and give you feed back right way.
Thank you.
+67
View File
@@ -0,0 +1,67 @@
<p align="center"><img width="600" alt="flasher" src="https://user-images.githubusercontent.com/10859693/102468596-03317180-4052-11eb-9df3-44dc6235b238.png"></p>
<h1 align="center">A powerful and flexible flash notifications system for PHP, Laravel, Symfony</h1>
<p align="center">
:eyes: PHP Flasher helps you to add flash notifications to your PHP projects.
This library was developed with the idea that you should be able to add flash notification to your application with ease and with few lines of code.
No application-wide rewrites and no big investments upfront.
</p>
<p align="center">
<a href="https://github.com/php-flasher/flasher">
<img src="https://img.shields.io/badge/source-php--flasher/flasher-blue.svg?style=flat-square">
</a>
<a href="https://github.com/php-flasher/flasher/releases">
<img src="https://img.shields.io/github/tag/php-flasher/flasher.svg">
</a>
<a href="https://github.com/php-flasher/flasher/blob/master/LICENSE">
<img src="https://img.shields.io/badge/license-MIT-brightgreen.svg">
</a>
<a href="https://packagist.org/packages/php-flasher/flasher">
<img src="https://img.shields.io/packagist/dt/php-flasher/flasher.svg">
</a>
<a href="https://packagist.org/packages/php-flasher/flasher">
<img src="https://img.shields.io/packagist/php-v/php-flasher/flasher.svg?style=flat-square">
</a>
</p>
# Why use PHP Flasher ?
The PHP Flasher project supports many notification libraries : __tailwindcss__, __bootstrap__, __toastr.js__, __sweet alert 2__, __pnotify__, __noty__, and __notyf__
and its highly extendable so you can add your custom notifications.
This library is designed, so you can take full control when creating you notifications :
> * Display multiple notifications
> * Sort and filter notifications
> * Render notification from JSON object
> * Limit the number of displayed notifications
> * Show notifications from different libraries at the same time
> * Framework angostic with integration for : Symfony and Laravel
> * Support templates
> * Easy migration from similar libraries.
> * Very flexible so you can add you own adapters
> * ...and more
## Official Documentation
Documentation for PHP Flasher can be found on the [PHP Flasher website](https://php-flasher.io).
### Contact
PHP Flasher is being actively developed by <a href="https://github.com/yoeunes">yoeunes</a>. You can reach out with questions, bug reports, or feature requests
on any of the following:
- [Github Issues](https://github.com/php-flasher/flasher/issues)
- [Github](https://github.com/yoeunes)
- [Twitter](https://twitter.com/yoeunes)
- [Linkedin](https://www.linkedin.com/in/younes-khoubza/)
- [Email me directly](mailto:younes.khoubza@gmail.com)
## License
PHP Flasher is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
<p align="center"> <b>Made with ❤️ by <a href="https://www.linkedin.com/in/younes-khoubza/">Younes KHOUBZA</a> <b> </p>
+3 -3
View File
@@ -5,9 +5,9 @@
"license": "MIT",
"authors": [
{
"name": "KHOUBZA Younes",
"name": "Younes KHOUBZA",
"email": "younes.khoubza@gmail.com",
"homepage": "https://github.com/yoeunes",
"homepage": "https://www.linkedin.com/in/younes-khoubza",
"role": "Developer"
}
],
@@ -16,7 +16,7 @@
"php-flasher/flasher-noty": "*",
"php-flasher/flasher-notyf": "*",
"php-flasher/flasher-pnotify": "*",
"php-flasher/flasher-sweet-alert": "*",
"php-flasher/flasher-sweetalert": "*",
"php-flasher/flasher-toastr": "*"
}
}
+4
View File
@@ -0,0 +1,4 @@
patreon: yoeunes
ko_fi: yoeunes
open_collective: php-flasher
custom: ['https://www.paypal.com/paypalme/yoeunes']
+22
View File
@@ -0,0 +1,22 @@
name: Auto Closer PR
on:
pull_request_target:
types: [opened]
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: superbrothers/close-pull-request@v3
with:
comment: |
Hi, thank you for your contribution.
Unfortunately, this repository is read-only. It's a split from our main monorepo repository.
We'd like to kindly ask you to move the contribution there - https://github.com/php-flasher/php-flasher.
We'll check it, review it and give you feed back right way.
Thank you.
+67
View File
@@ -0,0 +1,67 @@
<p align="center"><img width="600" alt="flasher" src="https://user-images.githubusercontent.com/10859693/102468596-03317180-4052-11eb-9df3-44dc6235b238.png"></p>
<h1 align="center">A powerful and flexible flash notifications system for PHP, Laravel, Symfony</h1>
<p align="center">
:eyes: PHP Flasher helps you to add flash notifications to your PHP projects.
This library was developed with the idea that you should be able to add flash notification to your application with ease and with few lines of code.
No application-wide rewrites and no big investments upfront.
</p>
<p align="center">
<a href="https://github.com/php-flasher/flasher">
<img src="https://img.shields.io/badge/source-php--flasher/flasher-blue.svg?style=flat-square">
</a>
<a href="https://github.com/php-flasher/flasher/releases">
<img src="https://img.shields.io/github/tag/php-flasher/flasher.svg">
</a>
<a href="https://github.com/php-flasher/flasher/blob/master/LICENSE">
<img src="https://img.shields.io/badge/license-MIT-brightgreen.svg">
</a>
<a href="https://packagist.org/packages/php-flasher/flasher">
<img src="https://img.shields.io/packagist/dt/php-flasher/flasher.svg">
</a>
<a href="https://packagist.org/packages/php-flasher/flasher">
<img src="https://img.shields.io/packagist/php-v/php-flasher/flasher.svg?style=flat-square">
</a>
</p>
# Why use PHP Flasher ?
The PHP Flasher project supports many notification libraries : __tailwindcss__, __bootstrap__, __toastr.js__, __sweet alert 2__, __pnotify__, __noty__, and __notyf__
and its highly extendable so you can add your custom notifications.
This library is designed, so you can take full control when creating you notifications :
> * Display multiple notifications
> * Sort and filter notifications
> * Render notification from JSON object
> * Limit the number of displayed notifications
> * Show notifications from different libraries at the same time
> * Framework angostic with integration for : Symfony and Laravel
> * Support templates
> * Easy migration from similar libraries.
> * Very flexible so you can add you own adapters
> * ...and more
## Official Documentation
Documentation for PHP Flasher can be found on the [PHP Flasher website](https://php-flasher.io).
### Contact
PHP Flasher is being actively developed by <a href="https://github.com/yoeunes">yoeunes</a>. You can reach out with questions, bug reports, or feature requests
on any of the following:
- [Github Issues](https://github.com/php-flasher/flasher/issues)
- [Github](https://github.com/yoeunes)
- [Twitter](https://twitter.com/yoeunes)
- [Linkedin](https://www.linkedin.com/in/younes-khoubza/)
- [Email me directly](mailto:younes.khoubza@gmail.com)
## License
PHP Flasher is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
<p align="center"> <b>Made with ❤️ by <a href="https://www.linkedin.com/in/younes-khoubza/">Younes KHOUBZA</a> <b> </p>
+3 -3
View File
@@ -5,9 +5,9 @@
"license": "MIT",
"authors": [
{
"name": "KHOUBZA Younes",
"name": "Younes KHOUBZA",
"email": "younes.khoubza@gmail.com",
"homepage": "https://github.com/yoeunes",
"homepage": "https://www.linkedin.com/in/younes-khoubza",
"role": "Developer"
}
],
@@ -16,7 +16,7 @@
"php-flasher/flasher-noty-symfony": "*",
"php-flasher/flasher-notyf-symfony": "*",
"php-flasher/flasher-pnotify-symfony": "*",
"php-flasher/flasher-sweet-alert-symfony": "*",
"php-flasher/flasher-sweetalert-symfony": "*",
"php-flasher/flasher-toastr-symfony": "*"
}
}
+4 -5
View File
@@ -1,7 +1,6 @@
parameters:
level: 9
paths:
- src/Prime
- src/Laravel
level: 8
excludes_analyse:
- vendor/*
- src
excludePaths:
- src/Symfony/Bridge/
+6 -25
View File
@@ -1,36 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
verbose="true"
stopOnFailure="true">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>
cacheResult="false"
stopOnFailure="true"
>
<testsuites>
<testsuite name="flasher prime">
<directory>tests/Prime</directory>
</testsuite>
<testsuite name="flasher">
<directory>tests/Prime</directory>
<directory>tests/Laravel</directory>
</testsuite>
<testsuite name="flasher toastr">
<directory>tests/Toastr/Laravel</directory>
</testsuite>
<testsuite name="flasher notyf">
<directory>tests/Notyf/Laravel</directory>
</testsuite>
<testsuite name="flasher sweet alert">
<directory>tests/SweetAlert/Laravel</directory>
</testsuite>
<testsuite name="flasher pnotify">
<directory>tests/Pnotify/Laravel</directory>
</testsuite>
<testsuite name="flasher noty">
<directory>tests/Noty/Laravel</directory>
</testsuite>
</testsuites>
</phpunit>
+5 -25
View File
@@ -1,36 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
cacheResult="false"
verbose="true"
stopOnFailure="true">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>
>
<testsuites>
<testsuite name="flasher prime">
<directory>tests/Prime</directory>
</testsuite>
<testsuite name="flasher">
<directory>tests/Prime</directory>
<directory>tests/Symfony</directory>
</testsuite>
<testsuite name="flasher toastr">
<directory>tests/Toastr/Symfony</directory>
</testsuite>
<testsuite name="flasher notyf">
<directory>tests/Notyf/Symfony</directory>
</testsuite>
<testsuite name="flasher sweet alert">
<directory>tests/SweetAlert/Symfony</directory>
</testsuite>
<testsuite name="flasher pnotify">
<directory>tests/Pnotify/Symfony</directory>
</testsuite>
<testsuite name="flasher noty">
<directory>tests/Noty/Symfony</directory>
</testsuite>
</testsuites>
</phpunit>
-18
View File
@@ -1,18 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
verbose="true"
stopOnFailure="true">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="flasher">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
-15
View File
@@ -1,15 +0,0 @@
; This file is for unifying the coding style for different editors and IDEs.
; More information at http://editorconfig.org
root = true
[*]
charset = utf-8
indent_size = 4
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
-13
View File
@@ -1,13 +0,0 @@
# Path-based git attributes
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
# Ignore all test and documentation with "export-ignore".
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/phpunit.xml.dist export-ignore
/.scrutinizer.yml export-ignore
/.styleci.yml export-ignore
/tests export-ignore
/.editorconfig export-ignore
-55
View File
@@ -1,55 +0,0 @@
# Contributing
Contributions are **welcome** and will be fully **credited**.
Please read and understand the contribution guide before creating an issue or pull request.
## Etiquette
This project is open source, and as such, the maintainers give their free time to build and maintain the source code
held within. They make the code freely available in the hope that it will be of use to other developers. It would be
extremely unfair for them to suffer abuse or anger for their hard work.
Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
world that developers are civilized and selfless people.
It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.
## Viability
When requesting or submitting new features, first consider whether it might be useful to others. Open
source projects are used by many developers, who may have entirely different needs to your own. Think about
whether or not your feature is likely to be used by other users of the project.
## Procedure
Before filing an issue:
- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
- Check to make sure your feature suggestion isn't already present within the project.
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
- Check the pull requests tab to ensure that the feature isn't already in progress.
Before submitting a pull request:
- Check the codebase to ensure that your feature doesn't already exist.
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
## Requirements
If the project maintainer has any additional requirements, you will find them listed here.
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer).
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
**Happy coding**!
-2
View File
@@ -1,5 +1,3 @@
# These are supported funding model platforms
patreon: yoeunes
ko_fi: yoeunes
open_collective: php-flasher
-3
View File
@@ -1,3 +0,0 @@
# Security Policy
If you discover any security related issues, please email younes.khoubza@gmail.com instead of using the issue tracker.
-7
View File
@@ -1,7 +0,0 @@
version: 2
updates:
- package-ecosystem: composer
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
+22
View File
@@ -0,0 +1,22 @@
name: Auto Closer PR
on:
pull_request_target:
types: [opened]
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: superbrothers/close-pull-request@v3
with:
comment: |
Hi, thank you for your contribution.
Unfortunately, this repository is read-only. It's a split from our main monorepo repository.
We'd like to kindly ask you to move the contribution there - https://github.com/php-flasher/php-flasher.
We'll check it, review it and give you feed back right way.
Thank you.
@@ -1,13 +0,0 @@
name: Close Pull Request
on:
pull_request_target:
types: [opened]
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: superbrothers/close-pull-request@v3
with:
comment: "Thank you for your pull request. However, you have submitted this PR on a read-only sub split of `php-flasher/php-flasher`. Please submit your PR on the https://github.com/php-flasher/php-flasher repository.<br><br>Thanks!"
-5
View File
@@ -1,5 +0,0 @@
.idea
vendor
composer.lock
.phpunit.result.cache
.phpcs-cache
-3
View File
@@ -1,3 +0,0 @@
<?php
namespace PHPSTORM_META;
View File
-76
View File
@@ -1,76 +0,0 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at younes.khoubza@gmail.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
+71 -20
View File
@@ -1,55 +1,106 @@
<?php
/*
* This file is part of the PHPFlasher package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
namespace Flasher\Cli\Laravel;
use Flasher\Cli\Laravel\ServiceProvider\ServiceProviderManager;
use Flasher\Cli\Prime\CliFactory;
use Flasher\Cli\Prime\EventListener\RenderListener;
use Flasher\Cli\Prime\Notify;
use Flasher\Cli\Prime\Presenter\CliPresenter;
use Flasher\Prime\EventDispatcher\EventDispatcherInterface;
use Flasher\Prime\FlasherInterface;
use Flasher\Prime\Response\ResponseManagerInterface;
use Illuminate\Container\Container;
use Illuminate\Support\ServiceProvider;
final class FlasherCliServiceProvider extends ServiceProvider
{
/**
* @return void
*/
public function boot()
{
$manager = new ServiceProviderManager($this);
$manager->boot();
$this->processConfiguration();
$this->registerRenderListener();
$this->registerPresenter();
}
/**
* Register the service provider.
* {@inheritdoc}
*/
public function register()
{
$manager = new ServiceProviderManager($this);
$manager->register();
$this->registerNotifierFactory();
$this->registerNotifier();
}
/**
* Get the services provided by the provider.
*
* @return string[]
* @return void
*/
public function provides()
private function processConfiguration()
{
return array(
'flasher.cli',
);
$name = 'flasher_cli';
$config = $this->app['config']; // @phpstan-ignore-line
$config->set($name, $config->get($name, array()));
}
/**
* @return Container
* @return void
*/
public function getApplication()
private function registerNotifierFactory()
{
return $this->app;
$this->app->singleton('flasher.cli', function (Container $app) {
return new CliFactory($app['flasher.storage_manager']); // @phpstan-ignore-line
});
$this->app->alias('flasher.cli', 'Flasher\Cli\Prime\CliFactory');
}
public function mergeConfigFrom($path, $key)
/**
* @return void
*/
private function registerNotifier()
{
parent::mergeConfigFrom($path, $key);
$this->app->singleton('flasher.notify', function (Container $app) {
/** @phpstan-ignore-next-line */
$title = $app['config']->get('flasher_cli.title', null);
$icons = $app['config']->get('flasher_cli.icons', array()); // @phpstan-ignore-line
return new Notify($title, $icons);
});
$this->app->alias('flasher.notify', 'Flasher\Cli\Prime\Notify');
$this->app->alias('flasher.notify', 'Flasher\Cli\Prime\NotifyInterface');
}
public function publishes(array $paths, $groups = null)
/**
* @return void
*/
private function registerRenderListener()
{
parent::publishes($paths, $groups);
/** @var FlasherInterface $flasher */
$flasher = $this->app['flasher'];
$this->app->extend('flasher.event_dispatcher', function (EventDispatcherInterface $dispatcher) use ($flasher) {
$dispatcher->addSubscriber(new RenderListener($flasher));
return $dispatcher;
});
}
/**
* @return void
*/
private function registerPresenter()
{
$this->app->extend('flasher.response_manager', function (ResponseManagerInterface $manager, Container $app) {
$manager->addPresenter(CliPresenter::NAME, new CliPresenter($app['flasher.notify'])); // @phpstan-ignore-line
return $manager;
});
}
}
+1 -21
View File
@@ -24,12 +24,6 @@
<a href="https://packagist.org/packages/php-flasher/flasher">
<img src="https://img.shields.io/packagist/php-v/php-flasher/flasher.svg?style=flat-square">
</a>
<a href="https://opencollective.com/php-flasher">
<img src="https://opencollective.com/php-flasher/tiers/backer/badge.svg?label=backer&color=brightgreen" />
</a>
<a href="https://opencollective.com/php-flasher">
<img src="https://opencollective.com/php-flasher/tiers/sponsor/badge.svg?label=sponsor&color=brightgreen" />
</a>
</p>
# Why use PHP Flasher ?
@@ -53,21 +47,7 @@ This library is designed, so you can take full control when creating you notific
## Official Documentation
Documentation for PHP Flasher can be found on the [PHP Flasher website](https://php-flasher.github.io/).
## Backers && Sponsors
Support this project by becoming a sponsor. Your name will show up in the Contribute page of all PHP Flasher installations as well as here with a link to your website!
Thank you to all our backers and sponsors! 🙏
<a href="https://opencollective.com/php-flasher#backers" target="_blank">
<img src="https://opencollective.com/php-flasher/backers.svg?width=890" title="Backers" alt="Backers">
</a>
<a href="https://opencollective.com/php-flasher#sponsors" target="_blank">
<img src="https://opencollective.com/php-flasher/sponsors.svg?width=890" title="Sponsors" alt="Sponsors">
</a>
Documentation for PHP Flasher can be found on the [PHP Flasher website](https://php-flasher.io).
### Contact
-110
View File
@@ -1,110 +0,0 @@
<?php
return array(
'render_all' => true,
'render_immediately' => true,
'title' => 'PHP Flasher',
'mute' => false,
'filter_criteria' => array(),
'icons' => array(),
'sounds' => array(),
'notifiers' => array(
'growl_notify' => array(
'enabled' => true,
'priority' => 0,
'binary' => 'growlnotify',
'binary_paths' => array(),
'title' => null,
'mute' => true,
'icons' => array(),
'sounds' => array(),
),
'kdialog_notifier' => array(
'enabled' => true,
'priority' => 0,
'binary' => 'kdialog',
'binary_paths' => array(),
'title' => null,
'mute' => true,
'icons' => array(),
'sounds' => array(),
),
'notifu_notifier' => array(
'enabled' => true,
'priority' => 0,
'binary' => 'notifu',
'binary_paths' => array(),
'title' => null,
'mute' => true,
'icons' => array(),
'sounds' => array(),
),
'notify_send' => array(
'enabled' => true,
'priority' => 2,
'binary' => 'notify-send',
'binary_paths' => array(),
'title' => null,
'mute' => true,
'icons' => array(),
'sounds' => array(),
),
'zenity' => array(
'enabled' => true,
'priority' => 1,
'binary' => 'zenity',
'binary_paths' => array(),
'title' => null,
'mute' => true,
'icons' => array(),
'sounds' => array(),
),
'snore_toast_notifier' => array(
'enabled' => true,
'priority' => 0,
'binary' => 'snoretoast',
'binary_paths' => array(),
'title' => null,
'mute' => true,
'icons' => array(),
'sounds' => array(),
),
'terminal_notifier_notifier' => array(
'enabled' => true,
'priority' => 0,
'binary' => 'terminal-notifier',
'binary_paths' => array(),
'title' => null,
'mute' => true,
'icons' => array(),
'sounds' => array(),
),
'toaster' => array(
'enabled' => true,
'priority' => 0,
'binary' => 'toast',
'binary_paths' => array(),
'title' => null,
'mute' => true,
'icons' => array(),
'sounds' => array(),
),
'apple_script' => array(
'enabled' => true,
'priority' => 1,
'binary' => 'osascript',
'binary_paths' => array(),
'title' => null,
'mute' => true,
'icons' => array(),
'sounds' => array(),
),
),
);
@@ -1,21 +0,0 @@
<?php
if (!function_exists('cliFlasher')) {
/**
* @param string $message
* @param string $type
*
* @return Flasher\Cli\Prime\CliFlasherInterface
*/
function cliFlasher($message = null, $renderImmediately = true, $type = 'success', array $options = array(), array $stamps = array())
{
/** @var Flasher\Cli\Prime\CliFlasherInterface $flasher */
$flasher = app('flasher.cli');
if (null === $message && 0 === func_num_args()) {
return $flasher;
}
return $flasher->with($stamps)->desktop($renderImmediately)->addFlash($type, $message, $options);
}
}
@@ -1,151 +0,0 @@
<?php
namespace Flasher\Cli\Laravel\ServiceProvider\Providers;
use Flasher\Cli\Laravel\FlasherCliServiceProvider;
use Flasher\Cli\Prime\CliNotificationFactory;
use Flasher\Cli\Prime\EventListener\RenderListener;
use Flasher\Cli\Prime\EventListener\StampsListener;
use Flasher\Cli\Prime\Notifier\AppleScriptNotifier;
use Flasher\Cli\Prime\Notifier\GrowlNotifyNotifier;
use Flasher\Cli\Prime\Notifier\KDialogNotifier;
use Flasher\Cli\Prime\Notifier\NotifuNotifier;
use Flasher\Cli\Prime\Notifier\NotifySendNotifier;
use Flasher\Cli\Prime\Notifier\SnoreToastNotifier;
use Flasher\Cli\Prime\Notifier\TerminalNotifierNotifier;
use Flasher\Cli\Prime\Notifier\ToasterNotifier;
use Flasher\Cli\Prime\Presenter\CliPresenter;
use Flasher\Cli\Prime\Stamp\DesktopStamp;
use Flasher\Prime\EventDispatcher\EventDispatcher;
use Flasher\Prime\Notification\NotificationBuilder;
use Flasher\Prime\Response\ResponseManager;
use Illuminate\Container\Container;
use Illuminate\Foundation\Application;
class Laravel implements ServiceProviderInterface
{
/**
* @var Container
*/
protected $app;
public function __construct(Container $app)
{
$this->app = $app;
}
public function shouldBeUsed()
{
return $this->app instanceof Application;
}
public function boot(FlasherCliServiceProvider $provider)
{
$provider->publishes(array(
flasher_path(__DIR__.'/../../Resources/config/config.php') => config_path('flasher_cli.php'),
), 'flasher-config');
$this->afterBoot();
}
public function afterBoot()
{
$this->app['flasher.response_manager']->addPresenter('cli', $this->app['flasher.presenter.cli']);
$this->app['flasher.event_dispatcher']->addSubscriber(new RenderListener($this->app['flasher.cli']));
$this->app['flasher.event_dispatcher']->addSubscriber(new StampsListener(
$this->app['flasher.config']->getFrom('flasher_cli', 'render_all', false),
$this->app['flasher.config']->getFrom('flasher_cli', 'render_immediately', true)
));
NotificationBuilder::macro('desktop', function ($renderImmediately = true) {
return $this->withStamp(new DesktopStamp($renderImmediately));
});
}
public function register(FlasherCliServiceProvider $provider)
{
$provider->mergeConfigFrom(flasher_path(__DIR__.'/../../Resources/config/config.php'), 'flasher_cli');
$this->registerServices();
}
public function registerServices()
{
$this->app->singleton('flasher.cli', function (Container $app) {
return new CliNotificationFactory(
$app['flasher.storage_manager'],
$app['flasher.response_manager'],
$app['flasher.config']->getFrom('flasher_cli', 'filter_criteria', array())
);
});
$this->app->singleton('flasher.cli.growl_notify', function (Container $app) {
return new GrowlNotifyNotifier(Laravel::createConfigFor($app, 'growl_notify'));
});
$this->app->singleton('flasher.cli.kdialog_notifier', function (Container $app) {
return new KDialogNotifier(Laravel::createConfigFor($app, 'kdialog_notifier'));
});
$this->app->singleton('flasher.cli.notifu_notifier', function (Container $app) {
return new NotifuNotifier(Laravel::createConfigFor($app, 'notifu_notifier'));
});
$this->app->singleton('flasher.cli.notify_send', function (Container $app) {
return new NotifySendNotifier(Laravel::createConfigFor($app, 'notify_send'));
});
$this->app->singleton('flasher.cli.snore_toast_notifier', function (Container $app) {
return new SnoreToastNotifier(Laravel::createConfigFor($app, 'snore_toast_notifier'));
});
$this->app->singleton('flasher.cli.terminal_notifier_notifier', function (Container $app) {
return new TerminalNotifierNotifier(Laravel::createConfigFor($app, 'terminal_notifier_notifier'));
});
$this->app->singleton('flasher.cli.toaster', function (Container $app) {
return new ToasterNotifier(Laravel::createConfigFor($app, 'toaster'));
});
$this->app->singleton('flasher.cli.zenity', function (Container $app) {
return new ToasterNotifier(Laravel::createConfigFor($app, 'zenity'));
});
$this->app->singleton('flasher.cli.apple_script', function (Container $app) {
return new AppleScriptNotifier(Laravel::createConfigFor($app, 'apple_script'));
});
$this->app->singleton('flasher.presenter.cli', function (Container $app) {
$presenter = new CliPresenter();
$presenter->addNotifier($app['flasher.cli.growl_notify']);
$presenter->addNotifier($app['flasher.cli.kdialog_notifier']);
$presenter->addNotifier($app['flasher.cli.notifu_notifier']);
$presenter->addNotifier($app['flasher.cli.notify_send']);
$presenter->addNotifier($app['flasher.cli.snore_toast_notifier']);
$presenter->addNotifier($app['flasher.cli.terminal_notifier_notifier']);
$presenter->addNotifier($app['flasher.cli.toaster']);
$presenter->addNotifier($app['flasher.cli.zenity']);
$presenter->addNotifier($app['flasher.cli.apple_script']);
return $presenter;
});
$this->app->alias('flasher.cli', 'Flasher\Cli\Prime\FlasherCli');
$this->app->alias('Flasher\Cli\Prime\FlasherCli', 'Flasher\Cli\Prime\CliFlasherInterface');
}
private static function createConfigFor(Container $app, $notifier)
{
$options = $app['flasher.config']->getFrom('flasher_cli', 'notifiers.'.$notifier);
$options['title'] = $app['flasher.config']->getFrom('flasher_cli', 'title');
$options['mute'] = $app['flasher.config']->getFrom('flasher_cli', 'mute');
$options['icons'] = array_replace_recursive($app['flasher.config']->getFrom('flasher_cli', 'icons'), $options['icons']);
$options['sounds'] = array_replace_recursive($app['flasher.config']->getFrom('flasher_cli', 'sounds'), $options['sounds']);
return $options;
}
}
@@ -1,30 +0,0 @@
<?php
namespace Flasher\Cli\Laravel\ServiceProvider\Providers;
use Flasher\Cli\Laravel\FlasherCliServiceProvider;
use Illuminate\Foundation\Application;
final class Laravel4 extends Laravel
{
public function shouldBeUsed()
{
return $this->app instanceof Application && 0 === strpos(Application::VERSION, '4.');
}
public function boot(FlasherCliServiceProvider $provider)
{
$provider->package(
'php-flasher/flasher-cli-laravel',
'flasher_cli',
flasher_path(__DIR__ . '/../../Resources')
);
$this->afterBoot();
}
public function register(FlasherCliServiceProvider $provider)
{
$this->registerServices();
}
}
@@ -1,17 +0,0 @@
<?php
namespace Flasher\Cli\Laravel\ServiceProvider\Providers;
use Flasher\Cli\Laravel\FlasherCliServiceProvider;
interface ServiceProviderInterface
{
/**
* @return bool
*/
public function shouldBeUsed();
public function boot(FlasherCliServiceProvider $provider);
public function register(FlasherCliServiceProvider $provider);
}
@@ -1,64 +0,0 @@
<?php
namespace Flasher\Cli\Laravel\ServiceProvider;
use Flasher\Cli\Laravel\FlasherCliServiceProvider;
use Flasher\Cli\Laravel\ServiceProvider\Providers\ServiceProviderInterface;
final class ServiceProviderManager
{
/**
* @var ServiceProviderInterface
*/
private $provider;
/**
* @var ServiceProviderInterface[]
*/
private $providers = array(
'Flasher\Cli\Laravel\ServiceProvider\Providers\Laravel4',
'Flasher\Cli\Laravel\ServiceProvider\Providers\Laravel',
);
/**
* @var FlasherCliServiceProvider
*/
private $notifyServiceProvider;
public function __construct(FlasherCliServiceProvider $notifyServiceProvider)
{
$this->notifyServiceProvider = $notifyServiceProvider;
}
public function boot()
{
$provider = $this->resolveServiceProvider();
$provider->boot($this->notifyServiceProvider);
}
public function register()
{
$provider = $this->resolveServiceProvider();
$provider->register($this->notifyServiceProvider);
}
/**
* @return ServiceProviderInterface
*/
private function resolveServiceProvider()
{
if ($this->provider instanceof ServiceProviderInterface) {
return $this->provider;
}
foreach ($this->providers as $providerClass) {
$provider = new $providerClass($this->notifyServiceProvider->getApplication());
if ($provider->shouldBeUsed()) {
return $this->provider = $provider;
}
}
throw new \InvalidArgumentException('Service Provider not found.');
}
}
View File
+8 -22
View File
@@ -2,42 +2,28 @@
"name": "php-flasher/flasher-cli-laravel",
"description": "PHP Flasher Laravel adapter for Cli",
"type": "library",
"keywords": [
"yoeunes",
"notify",
"php",
"laravel",
"symfony",
"Lumen",
"notifications",
"messages",
"alerts",
"pnotify",
"cli ",
"bundle",
"flex"
],
"homepage": "https://php-flasher.github.io/",
"keywords": ["yoeunes", "notify", "php", "laravel", "symfony", "Lumen", "notifications", "messages", "alerts", "pnotify", "cli ", "bundle", "flex"],
"homepage": "https://php-flasher.io",
"authors": [
{
"name": "Younes Khoubza",
"name": "Younes KHOUBZA",
"email": "younes.khoubza@gmail.com",
"homepage": "https://github.com/yoeunes",
"homepage": "https://www.linkedin.com/in/younes-khoubza",
"role": "Developer"
}
],
"license": "MIT",
"require": {
"php": ">=5.3",
"php-flasher/flasher-laravel": "^0.9",
"php-flasher/flasher-cli": "^0.9"
"php-flasher/flasher-laravel": "^1.0",
"php-flasher/flasher-cli": "^1.0"
},
"autoload": {
"psr-4": {
"Flasher\\Cli\\Laravel\\": ""
},
"files": [
"Resources/functions/cli.php"
"notify.php"
]
},
"extra": {
@@ -50,6 +36,6 @@
"config": {
"sort-packages": true
},
"minimum-stability": "dev",
"minimum-stability": "stable",
"prefer-stable": true
}
+27
View File
@@ -0,0 +1,27 @@
<?php
/*
* This file is part of the PHPFlasher package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
if (!function_exists('notify')) {
/**
* @param Flasher\Cli\Prime\Notification|string|null $notification
*
* @return Flasher\Cli\Prime\Notify
*/
function notify($notification = null)
{
/** @var Flasher\Cli\Prime\Notify $notifier */
$notifier = app('flasher.notify');
if (null === $notification || 0 === func_num_args()) {
return $notifier;
}
$notifier->send($notification);
return $notifier;
}
}
-15
View File
@@ -1,15 +0,0 @@
; This file is for unifying the coding style for different editors and IDEs.
; More information at http://editorconfig.org
root = true
[*]
charset = utf-8
indent_size = 4
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
-13
View File
@@ -1,13 +0,0 @@
# Path-based git attributes
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
# Ignore all test and documentation with "export-ignore".
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/phpunit.xml.dist export-ignore
/.scrutinizer.yml export-ignore
/.styleci.yml export-ignore
/tests export-ignore
/.editorconfig export-ignore
-55
View File
@@ -1,55 +0,0 @@
# Contributing
Contributions are **welcome** and will be fully **credited**.
Please read and understand the contribution guide before creating an issue or pull request.
## Etiquette
This project is open source, and as such, the maintainers give their free time to build and maintain the source code
held within. They make the code freely available in the hope that it will be of use to other developers. It would be
extremely unfair for them to suffer abuse or anger for their hard work.
Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
world that developers are civilized and selfless people.
It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.
## Viability
When requesting or submitting new features, first consider whether it might be useful to others. Open
source projects are used by many developers, who may have entirely different needs to your own. Think about
whether or not your feature is likely to be used by other users of the project.
## Procedure
Before filing an issue:
- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
- Check to make sure your feature suggestion isn't already present within the project.
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
- Check the pull requests tab to ensure that the feature isn't already in progress.
Before submitting a pull request:
- Check the codebase to ensure that your feature doesn't already exist.
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
## Requirements
If the project maintainer has any additional requirements, you will find them listed here.
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer).
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
**Happy coding**!
-2
View File
@@ -1,5 +1,3 @@
# These are supported funding model platforms
patreon: yoeunes
ko_fi: yoeunes
open_collective: php-flasher
-3
View File
@@ -1,3 +0,0 @@
# Security Policy
If you discover any security related issues, please email younes.khoubza@gmail.com instead of using the issue tracker.
-7
View File
@@ -1,7 +0,0 @@
version: 2
updates:
- package-ecosystem: composer
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
+22
View File
@@ -0,0 +1,22 @@
name: Auto Closer PR
on:
pull_request_target:
types: [opened]
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: superbrothers/close-pull-request@v3
with:
comment: |
Hi, thank you for your contribution.
Unfortunately, this repository is read-only. It's a split from our main monorepo repository.
We'd like to kindly ask you to move the contribution there - https://github.com/php-flasher/php-flasher.
We'll check it, review it and give you feed back right way.
Thank you.
-13
View File
@@ -1,13 +0,0 @@
name: Close Pull Request
on:
pull_request_target:
types: [opened]
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: superbrothers/close-pull-request@v3
with:
comment: "Thank you for your pull request. However, you have submitted this PR on a read-only sub split of `php-flasher/php-flasher`. Please submit your PR on the https://github.com/php-flasher/php-flasher repository.<br><br>Thanks!"
-5
View File
@@ -1,5 +0,0 @@
.idea
vendor
composer.lock
.phpunit.result.cache
.phpcs-cache
+2 -2
View File
@@ -3,9 +3,9 @@
namespace PHPSTORM_META;
override(\Flasher\Prime\FlasherInterface::create(), map([
'cli' => \Flasher\Cli\Prime\CliNotificationFactory::class
'cli' => \Flasher\Cli\Prime\CliFactory::class
]));
override(\Flasher\Prime\FlasherInterface::using(), map([
'cli' => \Flasher\Cli\Prime\CliNotificationFactory::class
'cli' => \Flasher\Cli\Prime\CliFactory::class
]));
View File
-76
View File
@@ -1,76 +0,0 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at younes.khoubza@gmail.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
@@ -1,20 +1,26 @@
<?php
/*
* This file is part of the PHPFlasher package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
namespace Flasher\Cli\Prime;
use Flasher\Prime\Notification\NotificationBuilder;
final class CliNotificationBuilder extends NotificationBuilder
final class CliBuilder extends NotificationBuilder
{
/**
* @param string $title
*
* @return self
* @return static
*/
public function title($title)
{
/** @var Notification $notification */
$notification = $this->envelope->getNotification();
$notification->setTitle(addslashes($title));
$notification->setTitle($title);
return $this;
}
@@ -22,10 +28,11 @@ final class CliNotificationBuilder extends NotificationBuilder
/**
* @param string $icon
*
* @return self
* @return static
*/
public function icon($icon)
{
/** @var Notification $notification */
$notification = $this->envelope->getNotification();
$notification->setIcon($icon);
+18
View File
@@ -0,0 +1,18 @@
<?php
/*
* This file is part of the PHPFlasher package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
namespace Flasher\Cli\Prime;
use Flasher\Prime\Factory\NotificationFactory;
final class CliFactory extends NotificationFactory
{
public function createNotificationBuilder()
{
return new CliBuilder($this->getStorageManager(), new Notification(), 'cli');
}
}
-11
View File
@@ -1,11 +0,0 @@
<?php
namespace Flasher\Cli\Prime;
/**
* @mixin CliNotificationBuilder
*/
interface CliFlasherInterface
{
public function render(array $criteria = array(), $merge = true);
}
-56
View File
@@ -1,56 +0,0 @@
<?php
namespace Flasher\Cli\Prime;
use Flasher\Prime\Notification\Notification;
final class CliNotification extends Notification
{
/**
* @var string
*/
private $title;
/** @var string */
private $icon;
/**
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* @param string $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* @return string
*/
public function getIcon()
{
return $this->icon;
}
/**
* @param string $icon
*/
public function setIcon($icon)
{
$this->icon = $icon;
}
public function toArray()
{
return array_merge(parent::toArray(), array(
'title' => $this->getTitle(),
'icon' => $this->getIcon(),
));
}
}
-38
View File
@@ -1,38 +0,0 @@
<?php
namespace Flasher\Cli\Prime;
use Flasher\Prime\Factory\NotificationFactory;
use Flasher\Prime\Response\ResponseManagerInterface;
use Flasher\Prime\Storage\StorageManagerInterface;
final class CliNotificationFactory extends NotificationFactory implements CliFlasherInterface
{
private $responseManager;
private $filterCriteria;
public function __construct(
StorageManagerInterface $storageManager,
ResponseManagerInterface $responseManager,
array $filterCriteria = array()
) {
parent::__construct($storageManager);
$this->responseManager = $responseManager;
$this->filterCriteria = $filterCriteria;
}
public function render(array $criteria = array(), $merge = true)
{
if ($merge) {
$criteria = $this->filterCriteria + $criteria;
}
return $this->responseManager->render($criteria, 'cli');
}
public function createNotificationBuilder()
{
return new CliNotificationBuilder($this->getStorageManager(), new CliNotification(), 'cli');
}
}
+18 -17
View File
@@ -1,43 +1,44 @@
<?php
/*
* This file is part of the PHPFlasher package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
namespace Flasher\Cli\Prime\EventListener;
use Flasher\Cli\Prime\CliFlasherInterface;
use Flasher\Cli\Prime\Stamp\DesktopStamp;
use Flasher\Prime\Envelope;
use Flasher\Cli\Prime\Presenter\CliPresenter;
use Flasher\Prime\EventDispatcher\Event\PostPersistEvent;
use Flasher\Prime\EventDispatcher\EventListener\EventSubscriberInterface;
use Flasher\Prime\FlasherInterface;
final class RenderListener implements EventSubscriberInterface
{
/**
* @var FlasherInterface
*/
private $flasher;
public function __construct(CliFlasherInterface $flasher)
public function __construct(FlasherInterface $flasher)
{
$this->flasher = $flasher;
}
/**
* @param PostPersistEvent $event
* @return void
*/
public function __invoke($event)
public function __invoke(PostPersistEvent $event)
{
if (PHP_SAPI !== 'cli') {
if ('cli' !== \PHP_SAPI) {
return;
}
$callback = function(Envelope $envelope) {
$stamp = $envelope->get('Flasher\Cli\Prime\Stamp\DesktopStamp');
if (!$stamp instanceof DesktopStamp) {
return false;
}
return $stamp->isRenderImmediately();
};
$this->flasher->render(array('filter' => $callback));
$this->flasher->render(array(), CliPresenter::NAME);
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents()
{
return 'Flasher\Prime\EventDispatcher\Event\PostPersistEvent';
@@ -1,48 +0,0 @@
<?php
namespace Flasher\Cli\Prime\EventListener;
use Flasher\Cli\Prime\Stamp\DesktopStamp;
use Flasher\Prime\Envelope;
use Flasher\Prime\EventDispatcher\Event\PersistEvent;
use Flasher\Prime\EventDispatcher\Event\UpdateEvent;
use Flasher\Prime\EventDispatcher\EventListener\EventSubscriberInterface;
final class StampsListener implements EventSubscriberInterface
{
private $renderAll;
private $renderImmediately;
public function __construct($renderAll, $renderImmediately)
{
$this->renderAll = $renderAll;
$this->renderImmediately = $renderImmediately;
}
/**
* @param PersistEvent|UpdateEvent $event
*/
public function __invoke($event)
{
if (PHP_SAPI !== 'cli') {
return;
}
foreach ($event->getEnvelopes() as $envelope) {
$this->attachStamps($envelope);
}
}
public static function getSubscribedEvents()
{
return 'Flasher\Prime\EventDispatcher\Event\PersistEvent';
}
private function attachStamps(Envelope $envelope)
{
$stamp = $envelope->get('Flasher\Cli\Prime\Stamp\DesktopStamp');
if (null === $stamp && true === $this->renderAll) {
$envelope->withStamp(new DesktopStamp($this->renderImmediately));
}
}
}
+228
View File
@@ -0,0 +1,228 @@
<?php
/*
* This file is part of the PHPFlasher package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
namespace Flasher\Cli\Prime;
use Flasher\Prime\Notification\Envelope;
use Flasher\Prime\Notification\Notification as BaseNotification;
use Flasher\Prime\Notification\NotificationInterface;
final class Notification extends BaseNotification
{
/**
* @var string|null
*/
private $title;
/**
* @var string|null
*/
private $icon;
/**
* @param string|null $message
* @param string|null $title
* @param string|null $icon
* @param string $type
* @param array<string, mixed> $options
*/
public function __construct($message = null, $title = null, $icon = null, $type = self::INFO, array $options = array())
{
$this->message = $message;
$this->title = $title;
$this->icon = $icon;
$this->type = $type;
$this->options = $options;
}
/**
* @param Notification|string $notification
*
* @return static
*/
public static function wrap($notification)
{
if ($notification instanceof Notification) {
return $notification;
}
return self::create($notification);
}
/**
* @param string $message
* @param string|null $title
* @param string|null $icon
* @param string $type
* @param array<string, mixed> $options
*
* @return static
*/
public static function create($message, $title = null, $icon = null, $type = self::INFO, array $options = array())
{
return new self($message, $title, $icon, $type, $options);
}
/**
* @param string $message
* @param string|null $title
* @param string|null $icon
* @param array<string, mixed> $options
*
* @return static
*/
public static function error($message, $title = null, $icon = null, array $options = array())
{
return self::create($message, $title, $icon, NotificationInterface::ERROR, $options);
}
/**
* @param string $message
* @param string|null $title
* @param string|null $icon
* @param array<string, mixed> $options
*
* @return static
*/
public static function info($message, $title = null, $icon = null, array $options = array())
{
return self::create($message, $title, $icon, NotificationInterface::INFO, $options);
}
/**
* @param string $message
* @param string|null $title
* @param string|null $icon
* @param array<string, mixed> $options
*
* @return static
*/
public static function success($message, $title = null, $icon = null, array $options = array())
{
return self::create($message, $title, $icon, NotificationInterface::SUCCESS, $options);
}
/**
* @param string $message
* @param string|null $title
* @param string|null $icon
* @param array<string, mixed> $options
*
* @return static
*/
public static function warning($message, $title = null, $icon = null, array $options = array())
{
return self::create($message, $title, $icon, NotificationInterface::WARNING, $options);
}
/**
* {@inheritdoc}
*/
public function getMessage()
{
$message = parent::getMessage();
if (\is_string($message)) {
$message = addslashes($message);
}
return $message;
}
/**
* {@inheritdoc}
*/
public function getOption($name, $default = null)
{
$option = parent::getOption($name, $default);
if (\is_string($option)) {
$option = addslashes($option);
}
return $option;
}
/**
* @return string|null
*/
public function getTitle()
{
$title = $this->title;
if (\is_string($title)) {
$title = addslashes($title);
}
return $title;
}
/**
* @param string|null $title
*
* @return static
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* @return string|null
*/
public function getIcon()
{
return $this->icon;
}
/**
* @param string|null $icon
*
* @return static
*/
public function setIcon($icon)
{
$this->icon = $icon;
return $this;
}
/**
* {@inheritdoc}
*/
public function toArray()
{
return array_merge(parent::toArray(), array(
'title' => $this->getTitle(),
'icon' => $this->getIcon(),
));
}
/**
* @return static
*/
public static function fromEnvelope(Envelope $envelope)
{
$self = new self();
$self->setType($envelope->getType());
$self->setMessage($envelope->getMessage());
$self->setOptions($envelope->getOptions());
$notification = $envelope->getNotification();
if (!$notification instanceof self) {
return $self;
}
$self->setTitle($notification->getTitle());
$self->setIcon($notification->getIcon());
return $self;
}
}
-146
View File
@@ -1,146 +0,0 @@
<?php
namespace Flasher\Cli\Prime\Notifier;
use Flasher\Cli\Prime\CliNotification;
use Flasher\Cli\Prime\System\Path;
use Flasher\Cli\Prime\System\Program;
use Flasher\Prime\Envelope;
use Flasher\Prime\Notification\NotificationInterface;
abstract class AbstractNotifier implements NotifierInterface
{
protected $options;
public function __construct(array $options = array())
{
$this->configureOptions($options);
}
public function render(array $envelopes)
{
foreach ($envelopes as $envelope) {
$this->renderEnvelope($envelope);
}
}
abstract public function renderEnvelope(Envelope $envelope);
public function isSupported()
{
return $this->options['is_supported'];
}
public function getPriority()
{
return $this->options['priority'];
}
public function getBinary()
{
return $this->options['binary'];
}
public function getBinaryPaths()
{
return $this->options['binary_paths'];
}
public function getProgram()
{
if (Program::exist($this->getBinary())) {
return $this->getBinary();
}
foreach ((array)$this->getBinaryPaths() as $path) {
$path = Path::realpath($path);
if (file_exists($path)) {
return $path;
}
}
return null;
}
public function getTitle(Envelope $envelope)
{
$notification = $envelope->getNotification();
if (method_exists($notification, 'getTitle') && null !== $notification->getTitle()) {
return addslashes($notification->getTitle());
}
return addslashes($this->options['title']);
}
public function isEnabled()
{
return $this->options['enabled'];
}
/**
* @param Envelope $envelope
*
* @return string
*/
public function getIcon(Envelope $envelope)
{
$notification = $envelope->getNotification();
if ($notification instanceof CliNotification && $notification->getIcon()) {
return Path::realpath($notification->getIcon());
}
$type = $envelope->getType();
if (isset($this->options['icons'][$type]) && file_exists($this->options['icons'][$type])) {
return Path::realpath($this->options['icons'][$type]);
}
return Path::realpath(__DIR__.'/../Resources/icons/info.png');
}
public function playSound($type = null)
{
if ($this->options['mute']) {
return;
}
\exec('paplay '.$this->getSound($type));
}
public function getSound($type)
{
if (isset($this->options['sounds'][$type]) && file_exists($this->options['sounds'][$type])) {
return Path::realpath($this->options['sounds'][$type]);
}
return Path::realpath(__DIR__.'/../Resources/sounds/info.wav');
}
public function configureOptions(array $options)
{
$default = array(
'enabled' => true,
'priority' => 0,
'binary' => null,
'binary_paths' => array(),
'title' => 'PHPFlasher',
'icons' => array(
NotificationInterface::TYPE_SUCCESS => Path::realpath(__DIR__.'/../Resources/icons/success.png'),
NotificationInterface::TYPE_ERROR => Path::realpath(__DIR__.'/../Resources/icons/error.png'),
NotificationInterface::TYPE_INFO => Path::realpath(__DIR__.'/../Resources/icons/info.png'),
NotificationInterface::TYPE_WARNING => Path::realpath(__DIR__.'/../Resources/icons/warning.png'),
),
'mute' => false,
'sounds' => array(
NotificationInterface::TYPE_SUCCESS => Path::realpath(__DIR__.'/../Resources/sounds/success.wav'),
NotificationInterface::TYPE_ERROR => Path::realpath(__DIR__.'/../Resources/sounds/error.wav'),
NotificationInterface::TYPE_INFO => Path::realpath(__DIR__.'/../Resources/sounds/info.wav'),
NotificationInterface::TYPE_WARNING => Path::realpath(__DIR__.'/../Resources/sounds/warning.wav'),
),
);
$this->options = array_replace_recursive($default, $options);
}
}
@@ -0,0 +1,57 @@
<?php
/*
* This file is part of the PHPFlasher package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
namespace Flasher\Cli\Prime\Notifier;
use Flasher\Cli\Prime\Notification;
use Flasher\Cli\Prime\System\Command;
use Flasher\Cli\Prime\System\OS;
final class AppleScriptBaseNotifier extends BaseNotifier
{
/**
* {@inheritdoc}
*/
public function send($notification)
{
$notification = Notification::wrap($notification);
$cmd = new Command($this->getProgram());
$cmd
->addArgument(sprintf('display notification "%s"', $notification->getMessage()))
->addArgument(sprintf('with title "%s"', $notification->getTitle()));
/** @var string $subtitle */
$subtitle = $notification->getOption('subtitle');
if ($subtitle) {
$cmd->addArgument(sprintf('subtitle "%s"', $subtitle));
}
$cmd->run();
}
/**
* {@inheritdoc}
*/
public function isSupported()
{
if (!$this->getProgram()) {
return false;
}
return OS::isMacOS() && version_compare(OS::getMacOSVersion(), '10.9.0', '>=');
}
/**
* {@inheritdoc}
*/
public function getBinary()
{
return 'osascript';
}
}
@@ -1,51 +0,0 @@
<?php
namespace Flasher\Cli\Prime\Notifier;
use Flasher\Cli\Prime\System\Command;
use Flasher\Cli\Prime\System\OS;
use Flasher\Prime\Envelope;
final class AppleScriptNotifier extends AbstractNotifier
{
public function renderEnvelope(Envelope $envelope)
{
$cmd = new Command($this->getProgram());
$cmd
->addArgument(sprintf('display notification "%s"', $envelope->getMessage()))
->addArgument(sprintf('with title "%s"', $this->getTitle($envelope)));
$subtitle = $envelope->getOption('subtitle');
if ($subtitle) {
$cmd->addArgument(sprintf('subtitle "%s"', $subtitle));
}
$sound = $envelope->getOption('sound');
if ($sound) {
$cmd->addArgument(sprintf('sound name "%s"', $sound));
}
$cmd->run();
}
public function isSupported()
{
if (!$this->getProgram() || !$this->isEnabled()) {
return false;
}
return OS::isMacOS() && version_compare(OS::getMacOSVersion(), '10.9.0', '>=');
}
public function configureOptions(array $options)
{
$default = array(
'binary' => 'osascript',
);
$options = array_replace_recursive($default, $options);
parent::configureOptions($options);
}
}
+111
View File
@@ -0,0 +1,111 @@
<?php
/*
* This file is part of the PHPFlasher package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
namespace Flasher\Cli\Prime\Notifier;
use Flasher\Cli\Prime\Notification;
use Flasher\Cli\Prime\NotifyInterface;
use Flasher\Cli\Prime\System\Path;
use Flasher\Cli\Prime\System\Program;
use Flasher\Prime\Notification\NotificationInterface;
abstract class BaseNotifier implements NotifyInterface
{
/**
* {@inheritdoc}
*/
public function isSupported()
{
return true;
}
/**
* {@inheritdoc}
*/
public function getPriority()
{
return 0;
}
/**
* @return string|null
*/
public function getBinary()
{
return null;
}
/**
* @return string|string[]
*/
public function getBinaryPaths()
{
return array();
}
/**
* @return string|null
*/
public function getProgram()
{
if (Program::exist($this->getBinary())) {
return $this->getBinary();
}
foreach ((array) $this->getBinaryPaths() as $path) {
$path = Path::realpath($path);
if (file_exists($path)) {
return $path;
}
}
return null;
}
/**
* {@inheritdoc}
*/
public function success($message, $title = null, $options = array())
{
$this->type(NotificationInterface::SUCCESS, $message, $title, $options);
}
/**
* {@inheritdoc}
*/
public function info($message, $title = null, $options = array())
{
$this->type(NotificationInterface::INFO, $message, $title, $options);
}
/**
* {@inheritdoc}
*/
public function error($message, $title = null, $options = array())
{
$this->type(NotificationInterface::ERROR, $message, $title, $options);
}
/**
* {@inheritdoc}
*/
public function warning($message, $title = null, $options = array())
{
$this->type(NotificationInterface::WARNING, $message, $title, $options);
}
/**
* {@inheritdoc}
*/
public function type($type, $message, $title = null, $options = array())
{
$notification = new Notification($message, $title, null, $type, $options);
$this->send($notification);
}
}
@@ -0,0 +1,48 @@
<?php
/*
* This file is part of the PHPFlasher package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
namespace Flasher\Cli\Prime\Notifier;
use Flasher\Cli\Prime\Notification;
use Flasher\Cli\Prime\System\Command;
use Flasher\Cli\Prime\System\OS;
final class GrowlNotifyBaseNotifier extends BaseNotifier
{
/**
* {@inheritdoc}
*/
public function send($notification)
{
$notification = Notification::wrap($notification);
$cmd = new Command($this->getProgram());
$cmd
->addOption('--message', $notification->getMessage())
->addOption('--title', $notification->getTitle())
->addOption('--image', $notification->getIcon());
$cmd->run();
}
/**
* {@inheritdoc}
*/
public function isSupported()
{
return OS::isMacOS() && $this->getProgram();
}
/**
* {@inheritdoc}
*/
public function getBinary()
{
return 'growlnotify';
}
}
@@ -1,38 +0,0 @@
<?php
namespace Flasher\Cli\Prime\Notifier;
use Flasher\Cli\Prime\System\Command;
use Flasher\Cli\Prime\System\OS;
use Flasher\Prime\Envelope;
final class GrowlNotifyNotifier extends AbstractNotifier
{
public function renderEnvelope(Envelope $envelope)
{
$cmd = new Command($this->getProgram());
$cmd
->addOption('--message', $envelope->getMessage())
->addOption('--title', $this->getTitle($envelope))
->addOption('--image', $this->getIcon($envelope));
$cmd->run();
}
public function isSupported()
{
return $this->isEnabled() && OS::isMacOS() && $this->getProgram();
}
public function configureOptions(array $options)
{
$default = array(
'binary' => 'growlnotify',
);
$options = array_replace_recursive($default, $options);
parent::configureOptions($options);
}
}
@@ -0,0 +1,48 @@
<?php
/*
* This file is part of the PHPFlasher package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
namespace Flasher\Cli\Prime\Notifier;
use Flasher\Cli\Prime\Notification;
use Flasher\Cli\Prime\System\Command;
use Flasher\Cli\Prime\System\OS;
final class KDialogBaseNotifier extends BaseNotifier
{
/**
* {@inheritdoc}
*/
public function send($notification)
{
$notification = Notification::wrap($notification);
$cmd = new Command($this->getProgram());
$cmd
->addOption('--passivepopup', $notification->getMessage())
->addOption('--title', $notification->getTitle())
->addArgument(5);
$cmd->run();
}
/**
* {@inheritdoc}
*/
public function isSupported()
{
return OS::isUnix() && $this->getProgram();
}
/**
* {@inheritdoc}
*/
public function getBinary()
{
return 'kdialog';
}
}
@@ -1,38 +0,0 @@
<?php
namespace Flasher\Cli\Prime\Notifier;
use Flasher\Cli\Prime\System\Command;
use Flasher\Cli\Prime\System\OS;
use Flasher\Prime\Envelope;
final class KDialogNotifier extends AbstractNotifier
{
public function renderEnvelope(Envelope $envelope)
{
$cmd = new Command($this->getProgram());
$cmd
->addOption('--passivepopup', $envelope->getMessage())
->addOption('--title', $this->getTitle($envelope))
->addArgument(5);
$cmd->run();
}
public function isSupported()
{
return $this->isEnabled() && OS::isUnix() && $this->getProgram();
}
public function configureOptions(array $options)
{
$default = array(
'binary' => 'kdialog',
);
$options = array_replace_recursive($default, $options);
parent::configureOptions($options);
}
}
@@ -1,28 +0,0 @@
<?php
namespace Flasher\Cli\Prime\Notifier;
use Flasher\Prime\Envelope;
interface NotifierInterface
{
/**
* @param Envelope[] $envelopes
*/
public function render(array $envelopes);
/**
* @return bool
*/
public function isSupported();
/**
* @return int
*/
public function getPriority();
/**
* @return string
*/
public function getBinary();
}
@@ -0,0 +1,54 @@
<?php
/*
* This file is part of the PHPFlasher package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
namespace Flasher\Cli\Prime\Notifier;
use Flasher\Cli\Prime\Notification;
use Flasher\Cli\Prime\System\Command;
use Flasher\Cli\Prime\System\OS;
use Flasher\Cli\Prime\System\Path;
final class NotifuBaseNotifier extends BaseNotifier
{
public function send($notification)
{
$notification = Notification::wrap($notification);
$cmd = new Command($this->getProgram());
$cmd
->addOption('/m', $notification->getMessage())
->addOption('/p', $notification->getTitle())
->addOption('/i', $notification->getIcon());
$cmd->run();
}
/**
* {@inheritdoc}
*/
public function isSupported()
{
return OS::isWindowsSeven() && $this->getProgram();
}
/**
* {@inheritdoc}
*/
public function getBinary()
{
return 'notifu';
}
/**
* {@inheritdoc}
*/
public function getBinaryPaths()
{
return Path::realpath(__DIR__.'/../Resources/bin/notifu/notifu.exe');
}
}
-42
View File
@@ -1,42 +0,0 @@
<?php
namespace Flasher\Cli\Prime\Notifier;
use Flasher\Cli\Prime\System\Command;
use Flasher\Cli\Prime\System\OS;
use Flasher\Cli\Prime\System\Path;
use Flasher\Prime\Envelope;
final class NotifuNotifier extends AbstractNotifier
{
public function renderEnvelope(Envelope $envelope)
{
$cmd = new Command($this->getProgram());
$cmd
->addOption('/m', $envelope->getMessage())
->addOption('/p', $this->getTitle($envelope))
->addOption('/i', $this->getIcon($envelope));
$cmd->run();
}
public function isSupported()
{
return $this->isEnabled() && OS::isWindowsSeven() && $this->getProgram();
}
public function configureOptions(array $options)
{
$default = array(
'binary' => 'notifu',
'binary_paths' => array(
Path::realpath(__DIR__.'/../Resources/bin/notifu/notifu.exe'),
),
);
$options = array_replace_recursive($default, $options);
parent::configureOptions($options);
}
}
@@ -0,0 +1,51 @@
<?php
/*
* This file is part of the PHPFlasher package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
namespace Flasher\Cli\Prime\Notifier;
use Flasher\Cli\Prime\Notification;
use Flasher\Cli\Prime\System\Command;
use Flasher\Cli\Prime\System\OS;
final class NotifySendBaseNotifier extends BaseNotifier
{
/**
* {@inheritdoc}
*/
public function send($notification)
{
$notification = Notification::wrap($notification);
$cmd = new Command($this->getProgram());
$cmd
->addOption('--urgency', 'normal')
->addOption('--app-name', 'notify')
->addOption('--icon', $notification->getIcon())
->addOption('--expire-time', 1)
->addArgument($notification->getTitle())
->addArgument($notification->getMessage());
$cmd->run();
}
/**
* {@inheritdoc}
*/
public function isSupported()
{
return OS::isUnix() && $this->getProgram();
}
/**
* {@inheritdoc}
*/
public function getBinary()
{
return 'notify-send';
}
}
@@ -1,48 +0,0 @@
<?php
namespace Flasher\Cli\Prime\Notifier;
use Flasher\Cli\Prime\System\Command;
use Flasher\Cli\Prime\System\OS;
use Flasher\Prime\Envelope;
final class NotifySendNotifier extends AbstractNotifier
{
public function renderEnvelope(Envelope $envelope)
{
$cmd = new Command($this->getProgram());
$cmd
->addOption('--urgency', 'normal')
->addOption('--app-name', 'notify')
->addOption('--icon', $this->getIcon($envelope))
->addOption('--expire-time', $this->getExpireTime())
->addArgument($this->getTitle($envelope))
->addArgument($envelope->getMessage());
$cmd->run();
}
public function isSupported()
{
return $this->isEnabled() && OS::isUnix() && $this->getProgram();
}
public function getExpireTime()
{
return (int)$this->options['expire_time'];
}
public function configureOptions(array $options)
{
$default = array(
'binary' => 'notify-send',
'expire_time' => 1,
'priority' => 2,
);
$options = array_replace_recursive($default, $options);
parent::configureOptions($options);
}
}
@@ -0,0 +1,34 @@
<?php
/*
* This file is part of the PHPFlasher package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
namespace Flasher\Cli\Prime\Notifier;
final class NullBaseNotifier extends BaseNotifier
{
/**
* {@inheritdoc}
*/
public function send($notification)
{
}
/**
* {@inheritdoc}
*/
public function isSupported()
{
return false;
}
/**
* {@inheritdoc}
*/
public function getBinary()
{
return '';
}
}
-17
View File
@@ -1,17 +0,0 @@
<?php
namespace Flasher\Cli\Prime\Notifier;
use Flasher\Prime\Envelope;
final class NullNotifier extends AbstractNotifier
{
public function renderEnvelope(Envelope $envelope)
{
}
public function isSupported()
{
return false;
}
}
@@ -0,0 +1,61 @@
<?php
/*
* This file is part of the PHPFlasher package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
namespace Flasher\Cli\Prime\Notifier;
use Flasher\Cli\Prime\Notification;
use Flasher\Cli\Prime\System\Command;
use Flasher\Cli\Prime\System\OS;
use Flasher\Cli\Prime\System\Path;
final class SnoreToastBaseNotifier extends BaseNotifier
{
/**
* {@inheritdoc}
*/
public function send($notification)
{
$notification = Notification::wrap($notification);
$cmd = new Command($this->getProgram());
$cmd
->addOption('-m', $notification->getMessage())
->addOption('-t', $notification->getTitle())
->addOption('-p', $notification->getIcon());
$cmd->run();
}
/**
* {@inheritdoc}
*/
public function isSupported()
{
if (!$this->getProgram()) {
return false;
}
return OS::isWindowsEightOrHigher() || OS::isWindowsSubsystemForLinux();
}
/**
* {@inheritdoc}
*/
public function getBinary()
{
return 'snoretoast';
}
/**
* {@inheritdoc}
*/
public function getBinaryPaths()
{
return Path::realpath(__DIR__.'/../Resources/bin/snoreToast/snoretoast-x86.exe');
}
}
@@ -1,46 +0,0 @@
<?php
namespace Flasher\Cli\Prime\Notifier;
use Flasher\Cli\Prime\System\Command;
use Flasher\Cli\Prime\System\OS;
use Flasher\Cli\Prime\System\Path;
use Flasher\Prime\Envelope;
final class SnoreToastNotifier extends AbstractNotifier
{
public function renderEnvelope(Envelope $envelope)
{
$cmd = new Command($this->getProgram());
$cmd
->addOption('-m', $envelope->getMessage())
->addOption('-t', $this->getTitle($envelope))
->addOption('-p', $this->getIcon($envelope));
$cmd->run();
}
public function isSupported()
{
if (!$this->getProgram() || !$this->isEnabled()) {
return false;
}
return OS::isWindowsEightOrHigher() || OS::isWindowsSubsystemForLinux();
}
public function configureOptions(array $options)
{
$default = array(
'binary' => 'snoretoast',
'binary_paths' => array(
Path::realpath(__DIR__.'/../Resources/bin/snoreToast/snoretoast-x86.exe'),
),
);
$options = array_replace_recursive($default, $options);
parent::configureOptions($options);
}
}
@@ -0,0 +1,57 @@
<?php
/*
* This file is part of the PHPFlasher package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
namespace Flasher\Cli\Prime\Notifier;
use Flasher\Cli\Prime\Notification;
use Flasher\Cli\Prime\System\Command;
use Flasher\Cli\Prime\System\OS;
final class TerminalNotifierBaseNotifier extends BaseNotifier
{
/**
* {@inheritdoc}
*/
public function send($notification)
{
$notification = Notification::wrap($notification);
$cmd = new Command($this->getProgram());
$cmd
->addOption('-message', $notification->getMessage())
->addOption('-title', $notification->getTitle());
if (version_compare(OS::getMacOSVersion(), '10.9.0', '>=')) {
$cmd->addOption('-appIcon', $notification->getIcon());
}
/** @var string|null $url */
$url = $notification->getOption('url');
if ($url) {
$cmd->addOption('-open', $url);
}
$cmd->run();
}
/**
* {@inheritdoc}
*/
public function isSupported()
{
return OS::isMacOS() && $this->getProgram();
}
/**
* {@inheritdoc}
*/
public function getBinary()
{
return 'terminal-notifier';
}
}
@@ -1,46 +0,0 @@
<?php
namespace Flasher\Cli\Prime\Notifier;
use Flasher\Cli\Prime\System\Command;
use Flasher\Cli\Prime\System\OS;
use Flasher\Prime\Envelope;
final class TerminalNotifierNotifier extends AbstractNotifier
{
public function renderEnvelope(Envelope $envelope)
{
$cmd = new Command($this->getProgram());
$cmd
->addOption('-message', $envelope->getMessage())
->addOption('-title', $this->getTitle($envelope));
if (version_compare(OS::getMacOSVersion(), '10.9.0', '>=')) {
$cmd->addOption('-appIcon', $this->getIcon($envelope));
}
$url = $envelope->getOption('url');
if ($url) {
$cmd->addOption('-open', $url);
}
$cmd->run();
}
public function isSupported()
{
return $this->isEnabled() && OS::isMacOS() && $this->getProgram();
}
public function configureOptions(array $options)
{
$default = array(
'binary' => 'terminal-notifier',
);
$options = array_replace_recursive($default, $options);
parent::configureOptions($options);
}
}
@@ -0,0 +1,62 @@
<?php
/*
* This file is part of the PHPFlasher package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
namespace Flasher\Cli\Prime\Notifier;
use Flasher\Cli\Prime\Notification;
use Flasher\Cli\Prime\System\Command;
use Flasher\Cli\Prime\System\OS;
use Flasher\Cli\Prime\System\Path;
final class ToasterBaseNotifier extends BaseNotifier
{
/**
* {@inheritdoc}
*/
public function send($notification)
{
$notification = Notification::wrap($notification);
$cmd = new Command($this->getProgram());
$cmd
->addOption('-t', $notification->getTitle())
->addOption('-m', $notification->getMessage())
->addOption('-p', $notification->getIcon())
->addArgument('-w');
$cmd->run();
}
/**
* {@inheritdoc}
*/
public function isSupported()
{
if (!$this->getProgram()) {
return false;
}
return OS::isWindowsEightOrHigher() || OS::isWindowsSubsystemForLinux();
}
/**
* {@inheritdoc}
*/
public function getBinary()
{
return 'toast';
}
/**
* {@inheritdoc}
*/
public function getBinaryPaths()
{
return Path::realpath(__DIR__.'/../Resources/bin/toaster/toast.exe');
}
}

Some files were not shown because too many files have changed in this diff Show More