mirror of
https://github.com/php-flasher/php-flasher.git
synced 2026-03-31 15:07:47 +01:00
add php-notify classes and rename namespaces
This commit is contained in:
@@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
# 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
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
name: Running tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 * * * *'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
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.*]
|
||||||
|
dependency-version: [prefer-lowest, prefer-stable]
|
||||||
|
include:
|
||||||
|
- 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.*
|
||||||
|
|
||||||
|
name: L${{ matrix.laravel }} - P${{ matrix.php }} - ${{ matrix.dependency-version }}
|
||||||
|
|
||||||
|
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') }}
|
||||||
|
|
||||||
|
- 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_MEMORY_LIMIT=-1 composer require "laravel/framework:${{ matrix.laravel }}" "phpunit/phpunit:${{ matrix.phpunit }}" "orchestra/testbench:${{ matrix.testbench }}" monolog/monolog --no-interaction --no-update
|
||||||
|
COMPOSER_MEMORY_LIMIT=-1 composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
|
||||||
|
|
||||||
|
- name: Execute tests
|
||||||
|
run: vendor/bin/phpunit
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
.idea/
|
||||||
|
vendor/
|
||||||
|
composer.lock
|
||||||
|
.phpunit.result.cache
|
||||||
|
.phpcs-cache
|
||||||
+625
@@ -0,0 +1,625 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd"
|
||||||
|
>
|
||||||
|
<arg name="basepath" value="."/>
|
||||||
|
<arg name="extensions" value="php"/>
|
||||||
|
<arg name="parallel" value="80"/>
|
||||||
|
<arg name="cache" value=".phpcs-cache"/>
|
||||||
|
<arg name="colors"/>
|
||||||
|
|
||||||
|
<!-- Ignore warnings, show progress of the run and show sniff names -->
|
||||||
|
<arg value="nps"/>
|
||||||
|
|
||||||
|
<!-- Directories to be checked -->
|
||||||
|
<file>src</file>
|
||||||
|
<file>tests</file>
|
||||||
|
|
||||||
|
<!-- Import PSR-12 coding standard (base) -->
|
||||||
|
<rule ref="PSR12"/>
|
||||||
|
|
||||||
|
<!-- Force array element indentation with 4 spaces -->
|
||||||
|
<rule ref="Generic.Arrays.ArrayIndent"/>
|
||||||
|
|
||||||
|
<!-- Forbid `[...]` -->
|
||||||
|
<rule ref="Generic.Arrays.DisallowShortArraySyntax"/>
|
||||||
|
|
||||||
|
<!-- Forbid duplicate classes -->
|
||||||
|
<rule ref="Generic.Classes.DuplicateClassName"/>
|
||||||
|
|
||||||
|
<!-- Forbid empty statements -->
|
||||||
|
<rule ref="Generic.CodeAnalysis.EmptyStatement">
|
||||||
|
<!-- But allow empty catch -->
|
||||||
|
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch"/>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Forbid final methods in final classes -->
|
||||||
|
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
|
||||||
|
|
||||||
|
<!-- Forbid useless empty method overrides -->
|
||||||
|
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
|
||||||
|
|
||||||
|
<!-- Align corresponding assignment statement tokens -->
|
||||||
|
<rule ref="Generic.Formatting.MultipleStatementAlignment">
|
||||||
|
<properties>
|
||||||
|
<property name="error" value="true"/>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Force whitespace after a type cast -->
|
||||||
|
<rule ref="Generic.Formatting.SpaceAfterCast">
|
||||||
|
<properties>
|
||||||
|
<property name="spacing" value="0"/>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Force whitespace after `!` -->
|
||||||
|
<!-- <rule ref="Generic.Formatting.SpaceAfterNot"/> -->
|
||||||
|
|
||||||
|
<!-- Forbid PHP 4 constructors -->
|
||||||
|
<rule ref="Generic.NamingConventions.ConstructorName"/>
|
||||||
|
|
||||||
|
<!-- Forbid any content before opening tag -->
|
||||||
|
<rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/>
|
||||||
|
|
||||||
|
<!-- Forbid deprecated functions -->
|
||||||
|
<rule ref="Generic.PHP.DeprecatedFunctions"/>
|
||||||
|
|
||||||
|
<!-- Forbid alias functions, i.e. `sizeof()`, `delete()` -->
|
||||||
|
<rule ref="Generic.PHP.ForbiddenFunctions">
|
||||||
|
<properties>
|
||||||
|
<property name="forbiddenFunctions" type="array">
|
||||||
|
<element key="chop" value="rtrim"/>
|
||||||
|
<element key="close" value="closedir"/>
|
||||||
|
<element key="compact" value="null"/>
|
||||||
|
<element key="delete" value="unset"/>
|
||||||
|
<element key="doubleval" value="floatval"/>
|
||||||
|
<element key="extract" value="null"/>
|
||||||
|
<element key="fputs" value="fwrite"/>
|
||||||
|
<element key="ini_alter" value="ini_set"/>
|
||||||
|
<element key="is_double" value="is_float"/>
|
||||||
|
<element key="is_integer" value="is_int"/>
|
||||||
|
<element key="is_long" value="is_int"/>
|
||||||
|
<element key="is_null" value="null"/>
|
||||||
|
<element key="is_real" value="is_float"/>
|
||||||
|
<element key="is_writeable" value="is_writable"/>
|
||||||
|
<element key="join" value="implode"/>
|
||||||
|
<element key="key_exists" value="array_key_exists"/>
|
||||||
|
<element key="pos" value="current"/>
|
||||||
|
<element key="settype" value="null"/>
|
||||||
|
<element key="show_source" value="highlight_file"/>
|
||||||
|
<element key="sizeof" value="count"/>
|
||||||
|
<element key="strchr" value="strstr"/>
|
||||||
|
<element key="user_error" value="trigger_error"/>
|
||||||
|
</property>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Forbid useless inline string concatenation -->
|
||||||
|
<rule ref="Generic.Strings.UnnecessaryStringConcat">
|
||||||
|
<!-- But multiline is useful for readability -->
|
||||||
|
<properties>
|
||||||
|
<property name="allowMultiline" value="true"/>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Forbid backtick operator -->
|
||||||
|
<rule ref="Generic.PHP.BacktickOperator"/>
|
||||||
|
|
||||||
|
<!-- Force PHP 7 param and return types to be lowercased -->
|
||||||
|
<rule ref="Generic.PHP.LowerCaseType"/>
|
||||||
|
|
||||||
|
<!-- Forbid `php_sapi_name()` function -->
|
||||||
|
<rule ref="Generic.PHP.SAPIUsage"/>
|
||||||
|
|
||||||
|
<!-- Forbid comments starting with # -->
|
||||||
|
<rule ref="PEAR.Commenting.InlineComment"/>
|
||||||
|
|
||||||
|
<!-- Disallow else if in favor of elseif -->
|
||||||
|
<rule ref="PSR2.ControlStructures.ElseIfDeclaration.NotAllowed">
|
||||||
|
<type>error</type>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Require that single line arrays have the correct spacing: no space around brackets and one space after comma -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace"/>
|
||||||
|
|
||||||
|
<!-- Require comma after last element in multi-line array -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma"/>
|
||||||
|
|
||||||
|
<!-- Require presence of constant visibility -->
|
||||||
|
<!-- <rule ref="SlevomatCodingStandard.Classes.ClassConstantVisibility">
|
||||||
|
<properties>
|
||||||
|
<property name="fixable" value="true"/>
|
||||||
|
</properties>
|
||||||
|
</rule> -->
|
||||||
|
|
||||||
|
<!-- Forbid LSB for constants (static::FOO) -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>
|
||||||
|
|
||||||
|
<!-- Forbid more than one constant declared per statement -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition"/>
|
||||||
|
|
||||||
|
<!-- Forbid empty lines around type declarations -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces">
|
||||||
|
<properties>
|
||||||
|
<property name="linesCountAfterOpeningBrace" value="0"/>
|
||||||
|
<property name="linesCountBeforeClosingBrace" value="0"/>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Require usage of ::class instead of __CLASS__, get_class(), get_class($this), get_called_class() and get_parent_class() -->
|
||||||
|
<!-- <rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/> -->
|
||||||
|
|
||||||
|
<!-- Forbid uses of multiple traits separated by comma -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/>
|
||||||
|
|
||||||
|
<!-- Require no spaces before trait use, between trait uses and one space after trait uses -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Classes.TraitUseSpacing">
|
||||||
|
<properties>
|
||||||
|
<property name="linesCountAfterLastUse" value="1"/>
|
||||||
|
<property name="linesCountAfterLastUseWhenLastInClass" value="0"/>
|
||||||
|
<property name="linesCountBeforeFirstUse" value="0"/>
|
||||||
|
<property name="linesCountBetweenUses" value="0"/>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Forbid dead code -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements"/>
|
||||||
|
|
||||||
|
<!-- Forbid useless annotations - Git and LICENCE file provide more accurate information -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations">
|
||||||
|
<properties>
|
||||||
|
<property name="forbiddenAnnotations" type="array">
|
||||||
|
<element value="@api"/>
|
||||||
|
<element value="@author"/>
|
||||||
|
<element value="@category"/>
|
||||||
|
<element value="@copyright"/>
|
||||||
|
<element value="@created"/>
|
||||||
|
<element value="@license"/>
|
||||||
|
<element value="@package"/>
|
||||||
|
<element value="@since"/>
|
||||||
|
<element value="@subpackage"/>
|
||||||
|
<element value="@version"/>
|
||||||
|
</property>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Forbid empty comments -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
|
||||||
|
|
||||||
|
<!-- Forbid useless comments -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenComments">
|
||||||
|
<properties>
|
||||||
|
<property name="forbiddenCommentPatterns" type="array">
|
||||||
|
<element value="~^(?:(?!private|protected|static)\S+ )?(?:con|de)structor\.\z~i"/>
|
||||||
|
<element value="~^Created by .+\.\z~i"/>
|
||||||
|
<element value="~^(User|Date|Time): \S+\z~i"/>
|
||||||
|
<element value="~^\S+ [gs]etter\.\z~i"/>
|
||||||
|
<element value="~^(Class|Interface|Trait) \S+\z~i"/>
|
||||||
|
</property>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Require specific order of phpDoc annotations with empty newline between specific groups -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing">
|
||||||
|
<properties>
|
||||||
|
<property name="linesCountBeforeFirstContent" value="0"/>
|
||||||
|
<property name="linesCountAfterLastContent" value="0"/>
|
||||||
|
<property name="linesCountBetweenDescriptionAndAnnotations" value="1"/>
|
||||||
|
<property name="linesCountBetweenAnnotationsGroups" value="1"/>
|
||||||
|
<property name="annotationsGroups" type="array">
|
||||||
|
<element value="
|
||||||
|
@internal,
|
||||||
|
@deprecated,
|
||||||
|
"/>
|
||||||
|
<element value="
|
||||||
|
@link,
|
||||||
|
@see,
|
||||||
|
@uses,
|
||||||
|
"/>
|
||||||
|
<element value="@var"/>
|
||||||
|
<element value="@ORM\"/>
|
||||||
|
<element value="@param"/>
|
||||||
|
<element value="@return"/>
|
||||||
|
<element value="@throws"/>
|
||||||
|
</property>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Report invalid format of inline phpDocs with @var -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration"/>
|
||||||
|
|
||||||
|
<!-- Require comments with single line written as one-liners -->
|
||||||
|
<!-- <rule ref="SlevomatCodingStandard.Commenting.RequireOneLinePropertyDocComment"/> -->
|
||||||
|
|
||||||
|
<!-- Forbid assignments in conditions -->
|
||||||
|
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
|
||||||
|
|
||||||
|
<!-- Require consistent spacing for block structures -->
|
||||||
|
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing">
|
||||||
|
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeControlStructure" />
|
||||||
|
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeFirstControlStructure" />
|
||||||
|
<properties>
|
||||||
|
<property name="tokensToCheck" type="array">
|
||||||
|
<element value="T_IF" />
|
||||||
|
<element value="T_DO" />
|
||||||
|
<element value="T_WHILE" />
|
||||||
|
<element value="T_FOR" />
|
||||||
|
<element value="T_FOREACH" />
|
||||||
|
<element value="T_SWITCH" />
|
||||||
|
<element value="T_TRY" />
|
||||||
|
<element value="T_DEFAULT" />
|
||||||
|
</property>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Forbid fancy yoda conditions -->
|
||||||
|
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison"/> -->
|
||||||
|
|
||||||
|
<!-- Require usage of early exit -->
|
||||||
|
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
|
||||||
|
|
||||||
|
<!-- Require consistent spacing for jump statements -->
|
||||||
|
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
|
||||||
|
<properties>
|
||||||
|
<property name="linesCountBeforeWhenFirstInCaseOrDefault" value="0"/>
|
||||||
|
<property name="linesCountAfterWhenLastInCaseOrDefault" value="1"/>
|
||||||
|
<property name="linesCountAfterWhenLastInLastCaseOrDefault" value="0"/>
|
||||||
|
<property name="tokensToCheck" type="array">
|
||||||
|
<element value="T_RETURN" />
|
||||||
|
<element value="T_THROW" />
|
||||||
|
<element value="T_YIELD" />
|
||||||
|
<element value="T_YIELD_FROM" />
|
||||||
|
</property>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Require language constructs without parentheses -->
|
||||||
|
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"/>
|
||||||
|
|
||||||
|
<!-- Require usage of null coalesce operator equal operator when possible -->
|
||||||
|
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator"/> -->
|
||||||
|
|
||||||
|
<!-- Require usage of null coalesce operator when possible -->
|
||||||
|
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/> -->
|
||||||
|
|
||||||
|
<!-- Forbid usage of conditions when a simple return can be used -->
|
||||||
|
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"/>
|
||||||
|
|
||||||
|
<!-- Forbid usage of boolean-only ternary operator usage (e.g. $foo ? true : false) -->
|
||||||
|
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator"/>
|
||||||
|
|
||||||
|
<!-- Forbid useless unreachable catch blocks -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
|
||||||
|
|
||||||
|
<!-- Require using Throwable instead of Exception -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/>
|
||||||
|
|
||||||
|
<!-- Ensure Arrow Functions declaration format -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration">
|
||||||
|
<properties>
|
||||||
|
<property name="spacesCountAfterKeyword" value="1"/>
|
||||||
|
<property name="spacesCountBeforeArrow" value="1"/>
|
||||||
|
<property name="spacesCountAfterArrow" value="1"/>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Require closures not referencing $this be static -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
|
||||||
|
|
||||||
|
<!-- Forbid unused variables passed to closures via `use` -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
|
||||||
|
|
||||||
|
<!-- Require presence of declare(strict_types=1) -->
|
||||||
|
<!-- <rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
|
||||||
|
<properties>
|
||||||
|
<property name="newlinesCountBetweenOpenTagAndDeclare" value="2"/>
|
||||||
|
<property name="spacesCountAroundEqualsSign" value="0"/>
|
||||||
|
<property name="newlinesCountAfterDeclare" value="2"/>
|
||||||
|
</properties>
|
||||||
|
</rule> -->
|
||||||
|
|
||||||
|
<!-- Require consistent spacing for block structures -->
|
||||||
|
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing"/>
|
||||||
|
|
||||||
|
<!-- Forbid unused use statements -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
|
||||||
|
<properties>
|
||||||
|
<property name="searchAnnotations" value="true"/>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Require use statements to be alphabetically sorted -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
|
||||||
|
|
||||||
|
<!-- Forbid fancy group uses -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Namespaces.DisallowGroupUse"/>
|
||||||
|
|
||||||
|
<!-- Forbid multiple use statements on same line -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine"/>
|
||||||
|
|
||||||
|
<!-- Require newlines around namespace declaration -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceSpacing"/>
|
||||||
|
|
||||||
|
<!-- Forbid using absolute class name references -->
|
||||||
|
<!-- <rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly"/> -->
|
||||||
|
|
||||||
|
<!-- Forbid superfluous leading backslash in use statements -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
|
||||||
|
|
||||||
|
<!-- Forbid useless uses of the same namespace -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Namespaces.UseFromSameNamespace"/>
|
||||||
|
|
||||||
|
<!-- Require empty newlines before and after uses -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing">
|
||||||
|
<properties>
|
||||||
|
<property name="linesCountAfterLastUse" value="1"/>
|
||||||
|
<property name="linesCountBeforeFirstUse" value="1"/>
|
||||||
|
<property name="linesCountBetweenUseTypes" value="1"/>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Forbid useless alias for classes, constants and functions -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>
|
||||||
|
|
||||||
|
<!-- Forbid weak comparisons -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
|
||||||
|
|
||||||
|
<!-- Forbid spacing before the negative operator `-` -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Operators.NegationOperatorSpacing"/>
|
||||||
|
|
||||||
|
<!-- Require the usage of assignment operators, eg `+=`, `.=` when possible -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator"/>
|
||||||
|
|
||||||
|
<!-- Require no spacing after spread operator -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Operators.SpreadOperatorSpacing"/>
|
||||||
|
|
||||||
|
<!-- Forbid `list(...)` syntax -->
|
||||||
|
<!-- <rule ref="SlevomatCodingStandard.PHP.ShortList"/> -->
|
||||||
|
|
||||||
|
<!-- Forbid use of longhand cast operators -->
|
||||||
|
<rule ref="SlevomatCodingStandard.PHP.TypeCast"/>
|
||||||
|
|
||||||
|
<!-- Forbid useless parentheses -->
|
||||||
|
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses"/>
|
||||||
|
|
||||||
|
<!-- Forbid useless semicolon `;` -->
|
||||||
|
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
|
||||||
|
|
||||||
|
<!-- Require use of short versions of scalar types (i.e. int instead of integer) -->
|
||||||
|
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
|
||||||
|
|
||||||
|
<!-- Require the `null` type hint to be in the last position of annotations -->
|
||||||
|
<rule ref="SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition"/>
|
||||||
|
|
||||||
|
<!-- Require ? when default value is null -->
|
||||||
|
<!-- <rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/> -->
|
||||||
|
|
||||||
|
<!-- Require one space between typehint and variable, require no space between nullability sign and typehint -->
|
||||||
|
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing"/>
|
||||||
|
|
||||||
|
<!-- Require space around colon in return types -->
|
||||||
|
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing">
|
||||||
|
<properties>
|
||||||
|
<property name="spacesCountBeforeColon" value="0"/>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Forbid useless @var for constants -->
|
||||||
|
<rule ref="SlevomatCodingStandard.TypeHints.UselessConstantTypeHint"/>
|
||||||
|
|
||||||
|
<!-- Forbid useless inherit doc comment -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Commenting.UselessInheritDocComment"/>
|
||||||
|
|
||||||
|
<!-- Forbid duplicated variables assignments -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable"/>
|
||||||
|
|
||||||
|
<!-- Forbid useless variables -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>
|
||||||
|
|
||||||
|
<!-- Forbid spaces around square brackets -->
|
||||||
|
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
|
||||||
|
|
||||||
|
<!-- Forbid class being in a file with different name -->
|
||||||
|
<rule ref="Squiz.Classes.ClassFileName"/>
|
||||||
|
|
||||||
|
<!-- Force `self::` for self-reference, force lower-case self, forbid spaces around `::` -->
|
||||||
|
<rule ref="Squiz.Classes.SelfMemberReference"/>
|
||||||
|
|
||||||
|
<!-- Forbid global functions -->
|
||||||
|
<rule ref="Squiz.Functions.GlobalFunction"/>
|
||||||
|
|
||||||
|
<!-- Force camelCase variables -->
|
||||||
|
<rule ref="Squiz.NamingConventions.ValidVariableName">
|
||||||
|
<exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore" />
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Force phpDoc alignment -->
|
||||||
|
<rule ref="Squiz.Commenting.DocCommentAlignment">
|
||||||
|
<!-- Allow extra spaces after star, i.e. for indented annotations -->
|
||||||
|
<exclude name="Squiz.Commenting.DocCommentAlignment.SpaceAfterStar"/>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Force array declaration structure -->
|
||||||
|
<rule ref="Squiz.Arrays.ArrayDeclaration">
|
||||||
|
<!-- Disable arrow alignment -->
|
||||||
|
<exclude name="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned"/>
|
||||||
|
<!-- Uses indentation of only single space -->
|
||||||
|
<exclude name="Squiz.Arrays.ArrayDeclaration.KeyNotAligned"/>
|
||||||
|
<!-- Allow multiple values on a single line -->
|
||||||
|
<exclude name="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed"/>
|
||||||
|
<!-- Disable alignment of braces -->
|
||||||
|
<exclude name="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned"/>
|
||||||
|
<!-- Disable alignment of values with opening brace -->
|
||||||
|
<exclude name="Squiz.Arrays.ArrayDeclaration.ValueNotAligned"/>
|
||||||
|
<!-- Checked by SlevomatCodingStandard.Arrays.TrailingArrayComma.MissingTrailingComma -->
|
||||||
|
<exclude name="Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast"/>
|
||||||
|
<exclude name="Squiz.Arrays.ArrayDeclaration.NoComma"/>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Force rules for function phpDoc -->
|
||||||
|
<rule ref="Squiz.Commenting.FunctionComment">
|
||||||
|
<!-- Allow `@throws` without description -->
|
||||||
|
<exclude name="Squiz.Commenting.FunctionComment.EmptyThrows"/>
|
||||||
|
<!-- Does not work properly with PHP 7 / short-named types -->
|
||||||
|
<exclude name="Squiz.Commenting.FunctionComment.IncorrectParamVarName"/>
|
||||||
|
<!-- Does not support collections, i.e. `string[]` -->
|
||||||
|
<exclude name="Squiz.Commenting.FunctionComment.IncorrectTypeHint"/>
|
||||||
|
<!-- Forces incorrect types -->
|
||||||
|
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturn"/>
|
||||||
|
<!-- Breaks with compound return types, i.e. `string|null` -->
|
||||||
|
<exclude name="Squiz.Commenting.FunctionComment.InvalidReturnNotVoid"/>
|
||||||
|
<!-- Breaks when all params are not documented -->
|
||||||
|
<exclude name="Squiz.Commenting.FunctionComment.InvalidTypeHint"/>
|
||||||
|
<!-- Doc comment is not required for every method -->
|
||||||
|
<exclude name="Squiz.Commenting.FunctionComment.Missing"/>
|
||||||
|
<!-- Do not require comments for `@param` -->
|
||||||
|
<exclude name="Squiz.Commenting.FunctionComment.MissingParamComment"/>
|
||||||
|
<!-- Do not require `@param` for all parameters -->
|
||||||
|
<exclude name="Squiz.Commenting.FunctionComment.MissingParamTag"/>
|
||||||
|
<!-- Do not require `@return` for void methods -->
|
||||||
|
<exclude name="Squiz.Commenting.FunctionComment.MissingReturn"/>
|
||||||
|
<!-- Comments don't have to be sentences -->
|
||||||
|
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullFullStop"/>
|
||||||
|
<!-- Comments don't have to be sentences -->
|
||||||
|
<exclude name="Squiz.Commenting.FunctionComment.ParamCommentNotCapital"/>
|
||||||
|
<!-- Breaks when all params are not documented -->
|
||||||
|
<exclude name="Squiz.Commenting.FunctionComment.ParamNameNoMatch"/>
|
||||||
|
<!-- Doesn't respect inheritance -->
|
||||||
|
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing"/>
|
||||||
|
<!-- `@throws` lines can often be read as a sentence,
|
||||||
|
i.e. `@throws RuntimeException if the file could not be written.` -->
|
||||||
|
<exclude name="Squiz.Commenting.FunctionComment.ThrowsNotCapital"/>
|
||||||
|
<!-- Doesn't work with self as typehint -->
|
||||||
|
<exclude name="Squiz.Commenting.FunctionComment.TypeHintMissing"/>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Forbid `AND` and `OR`, require `&&` and `||` -->
|
||||||
|
<rule ref="Squiz.Operators.ValidLogicalOperators"/>
|
||||||
|
|
||||||
|
<!-- Forbid `global` -->
|
||||||
|
<rule ref="Squiz.PHP.GlobalKeyword"/>
|
||||||
|
|
||||||
|
<!-- Forbid functions inside functions -->
|
||||||
|
<rule ref="Squiz.PHP.InnerFunctions"/>
|
||||||
|
|
||||||
|
<!-- Require PHP function calls in lowercase -->
|
||||||
|
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
|
||||||
|
|
||||||
|
<!-- Forbid `$this` inside static function -->
|
||||||
|
<rule ref="Squiz.Scope.StaticThisUsage"/>
|
||||||
|
|
||||||
|
<!-- Force whitespace before and after concatenation -->
|
||||||
|
<!-- <rule ref="Squiz.Strings.ConcatenationSpacing">
|
||||||
|
<properties>
|
||||||
|
<property name="spacing" value="0"/>
|
||||||
|
<property name="ignoreNewlines" value="true"/>
|
||||||
|
</properties>
|
||||||
|
</rule> -->
|
||||||
|
|
||||||
|
<!-- Forbid dead code -->
|
||||||
|
<rule ref="Squiz.PHP.NonExecutableCode"/>
|
||||||
|
|
||||||
|
<!-- Forbid strings in `"` unless necessary -->
|
||||||
|
<rule ref="Squiz.Strings.DoubleQuoteUsage"/>
|
||||||
|
<rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar">
|
||||||
|
<message>Variable "%s" not allowed in double quoted string; use sprintf() or concatenation instead</message>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Forbid braces around string in `echo` -->
|
||||||
|
<rule ref="Squiz.Strings.EchoedStrings"/>
|
||||||
|
|
||||||
|
<!-- Forbid spaces in type casts -->
|
||||||
|
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
|
||||||
|
|
||||||
|
<!-- Forbid blank line after function opening brace -->
|
||||||
|
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
|
||||||
|
|
||||||
|
<!-- Require 1 line before and after function, except at the top and bottom -->
|
||||||
|
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
|
||||||
|
<properties>
|
||||||
|
<property name="spacing" value="1" />
|
||||||
|
<property name="spacingBeforeFirst" value="0"/>
|
||||||
|
<property name="spacingAfterLast" value="0"/>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Require there be no space between increment/decrement operator and its operand -->
|
||||||
|
<rule ref="Generic.WhiteSpace.IncrementDecrementSpacing"/>
|
||||||
|
|
||||||
|
<!-- Require space after language constructs -->
|
||||||
|
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/>
|
||||||
|
|
||||||
|
<!-- Require space around logical operators -->
|
||||||
|
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
|
||||||
|
|
||||||
|
<!-- Forbid spaces around `->` operator -->
|
||||||
|
<rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing">
|
||||||
|
<properties>
|
||||||
|
<property name="ignoreNewlines" value="true"/>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Forbid spaces before semicolon `;` -->
|
||||||
|
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
|
||||||
|
|
||||||
|
<!-- Forbid superfluous whitespaces -->
|
||||||
|
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
|
||||||
|
<properties>
|
||||||
|
<!-- turned on by PSR2 -> turning back off -->
|
||||||
|
<property name="ignoreBlankLines" value="false"/>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines">
|
||||||
|
<!-- turned off by PSR2 -> turning back on -->
|
||||||
|
<severity>5</severity>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Checks that class/trait/interface members are in the correct order. -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Classes.ClassStructure"/>
|
||||||
|
|
||||||
|
<!-- Disallows use of continue without integer operand in switch because it emits a warning in PHP 7.3 and higher. -->
|
||||||
|
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowContinueWithoutIntegerOperandInSwitch"/>
|
||||||
|
|
||||||
|
<!-- Enforces reasonable end bracket placement for multiline arrays. -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Arrays.MultiLineArrayEndBracketPlacement"/>
|
||||||
|
|
||||||
|
<!-- Checks that there is a certain number of blank lines between properties. -->
|
||||||
|
<rule ref="SlevomatCodingStandard.Classes.PropertySpacing"/>
|
||||||
|
|
||||||
|
<!-- Require consistent spacing for jump statements -->
|
||||||
|
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
|
||||||
|
<properties>
|
||||||
|
<property name="tokensToCheck" type="array">
|
||||||
|
<element value="T_RETURN" />
|
||||||
|
<element value="T_THROW" />
|
||||||
|
<element value="T_YIELD" />
|
||||||
|
<element value="T_YIELD_FROM" />
|
||||||
|
</property>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Require consistent spacing for block structures -->
|
||||||
|
<rule ref="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing">
|
||||||
|
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeControlStructure" />
|
||||||
|
<exclude name="SlevomatCodingStandard.ControlStructures.BlockControlStructureSpacing.IncorrectLinesCountBeforeFirstControlStructure" />
|
||||||
|
<properties>
|
||||||
|
<property name="tokensToCheck" type="array">
|
||||||
|
<element value="T_IF" />
|
||||||
|
<element value="T_DO" />
|
||||||
|
<element value="T_WHILE" />
|
||||||
|
<element value="T_FOR" />
|
||||||
|
<element value="T_FOREACH" />
|
||||||
|
<element value="T_SWITCH" />
|
||||||
|
<element value="T_TRY" />
|
||||||
|
<element value="T_DEFAULT" />
|
||||||
|
</property>
|
||||||
|
</properties>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<!-- Requires new with parentheses. -->
|
||||||
|
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>
|
||||||
|
|
||||||
|
<!-- Disallows usage of array type hint syntax (eg. int[], bool[][]) in phpDocs in favour of generic type hint syntax (eg. array<int>, array<array<bool>>) -->
|
||||||
|
<!-- <rule ref="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax" />-->
|
||||||
|
</ruleset>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace PHPSTORM_META;
|
||||||
|
|
||||||
|
use Flasher\Prime\Envelope;
|
||||||
|
use Flasher\Prime\Flasher;
|
||||||
|
use Flasher\Prime\Presenter\PresenterManager;
|
||||||
|
use Flasher\Prime\Renderer\RendererManager;
|
||||||
|
|
||||||
|
override(Envelope::get(), type(0));
|
||||||
|
|
||||||
|
override(Flasher::make(''), map(['' => '@']));
|
||||||
|
override(RendererManager::make(''), map(['' => '@']));
|
||||||
|
override(PresenterManager::make(''), map(['' => '@']));
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Flasher\Laravel\Config;
|
||||||
|
|
||||||
|
use Illuminate\Config\Repository;
|
||||||
|
use Flasher\Prime\Config\ConfigInterface;
|
||||||
|
|
||||||
|
final class Config implements ConfigInterface
|
||||||
|
{
|
||||||
|
private $config;
|
||||||
|
|
||||||
|
private $separator;
|
||||||
|
|
||||||
|
public function __construct(Repository $config, $separator = '.')
|
||||||
|
{
|
||||||
|
$this->config = $config;
|
||||||
|
$this->separator = $separator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get($key, $default = null)
|
||||||
|
{
|
||||||
|
return $this->config->get('notify'.$this->separator.$key, $default);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Flasher\Laravel;
|
||||||
|
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Flasher\Laravel\ServiceProvider\ServiceProviderManager;
|
||||||
|
|
||||||
|
final class NotifyServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Bootstrap the application events.
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
$manager = new ServiceProviderManager($this);
|
||||||
|
$manager->boot();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the service provider.
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
$manager = new ServiceProviderManager($this);
|
||||||
|
$manager->register();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the services provided by the provider.
|
||||||
|
*
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public function provides()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'notify.producer',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Illuminate\Container\Container
|
||||||
|
*/
|
||||||
|
public function getApplication()
|
||||||
|
{
|
||||||
|
return $this->app;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function mergeConfigFrom($path, $key)
|
||||||
|
{
|
||||||
|
parent::mergeConfigFrom($path, $key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function publishes(array $paths, $groups = null)
|
||||||
|
{
|
||||||
|
parent::publishes($paths, $groups);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<p align="center"><img width="600" alt="notify" src="https://user-images.githubusercontent.com/10859693/100492861-fabfd800-3130-11eb-8c5e-242fff1706a9.png"></p>
|
||||||
|
|
||||||
|
<h1 align="center">Easy flash notifications for PHP, Laravel, Symfony, Lumen</h1>
|
||||||
|
|
||||||
|
<p align="center">:eyes: PHP Flasher library helps you to add flash notifications to your 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--notify/notify-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>
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
PHP Flasher library helps you to add flash notifications to your 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.
|
||||||
|
|
||||||
|
# Why use PHP Flasher ?
|
||||||
|
|
||||||
|
The PHP Flasher project supports a variety of notification libraries : __toastr.js__, __sweet alert 2__, __pnotify__ and __notyf__
|
||||||
|
and its highly extendable so you can add custom adapters.
|
||||||
|
|
||||||
|
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 response with Ajax or Websockets
|
||||||
|
> * Limit the number of displayed notifications
|
||||||
|
> * Show notifications from different adapters at the same time
|
||||||
|
> * implementations for popular frameworks : Symfony and Laravel
|
||||||
|
> * ...and more
|
||||||
|
|
||||||
|
|
||||||
|
## Official Documentation
|
||||||
|
|
||||||
|
Documentation for Valet can be found on the [PHP Flasher website](https://php-flasher.github.io/).
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
PHP Flasher is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'default' => 'toastr',
|
||||||
|
|
||||||
|
'scripts' => array(
|
||||||
|
'/vendor/php-flasher/flasher/assets/js/notify.js'
|
||||||
|
),
|
||||||
|
|
||||||
|
'styles' => array(
|
||||||
|
|
||||||
|
),
|
||||||
|
|
||||||
|
'adapters' => array(
|
||||||
|
|
||||||
|
),
|
||||||
|
|
||||||
|
'stamps_middlewares' => array(
|
||||||
|
|
||||||
|
),
|
||||||
|
);
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
/*!
|
||||||
|
* PHPNotify js 1.0.0
|
||||||
|
* https://github.com/php-flasher/flasher
|
||||||
|
* @license MIT licensed
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 Younes KHOUBZA
|
||||||
|
*/
|
||||||
|
(function (root, factory) {
|
||||||
|
if (typeof define === 'function' && define.amd) {
|
||||||
|
define([], factory(root));
|
||||||
|
} else if (typeof exports === 'object') {
|
||||||
|
module.exports = factory(root);
|
||||||
|
} else {
|
||||||
|
root.PHPNotify = factory(root);
|
||||||
|
}
|
||||||
|
})(typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : this, function (window) {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var exports = {};
|
||||||
|
|
||||||
|
exports.render = function (_settings) {
|
||||||
|
var settings = Object.assign({}, {
|
||||||
|
scripts: [],
|
||||||
|
styles: [],
|
||||||
|
options: [],
|
||||||
|
notifications: [],
|
||||||
|
}, _settings);
|
||||||
|
|
||||||
|
exports.addStyles(settings.styles, function () {
|
||||||
|
exports.addScripts(settings.scripts, function () {
|
||||||
|
var script = '';
|
||||||
|
|
||||||
|
settings.options.forEach(function (option) {
|
||||||
|
script += option + "\n";
|
||||||
|
});
|
||||||
|
|
||||||
|
script += "\n\n";
|
||||||
|
|
||||||
|
settings.notifications.forEach(function (notification) {
|
||||||
|
script += notification.code + "\n";
|
||||||
|
});
|
||||||
|
|
||||||
|
exports.parseScript(script);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.addStyles = function (urls, callback) {
|
||||||
|
if (0 === urls.length) {
|
||||||
|
if ("function" === typeof callback) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null !== document.querySelector(`link[href='${urls[0]}']`)) {
|
||||||
|
return exports.addStyles(urls.slice(1), callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
var tag = document.createElement('link');
|
||||||
|
|
||||||
|
tag.href = urls[0];
|
||||||
|
tag.type = 'text/css';
|
||||||
|
tag.rel = 'stylesheet';
|
||||||
|
tag.onload = function () {
|
||||||
|
exports.addStyles(urls.slice(1), callback);
|
||||||
|
};
|
||||||
|
|
||||||
|
document.head.appendChild(tag);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.addScripts = function (urls, callback) {
|
||||||
|
if (0 === urls.length) {
|
||||||
|
if ("function" === typeof callback) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null !== document.querySelector(`script[src='${urls[0]}']`)) {
|
||||||
|
return exports.addScripts(urls.slice(1), callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
var tag = document.createElement('script');
|
||||||
|
|
||||||
|
tag.src = urls[0];
|
||||||
|
tag.type = 'text/javascript';
|
||||||
|
tag.onload = function () {
|
||||||
|
exports.addScripts(urls.slice(1), callback);
|
||||||
|
};
|
||||||
|
|
||||||
|
document.body.appendChild(tag);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.parseScript = function (script) {
|
||||||
|
var tag = document.createElement('script');
|
||||||
|
|
||||||
|
tag.type = "text/javascript";
|
||||||
|
tag.text = script;
|
||||||
|
|
||||||
|
document.body.appendChild(tag);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
});
|
||||||
@@ -0,0 +1,136 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Flasher\Laravel\ServiceProvider\Providers;
|
||||||
|
|
||||||
|
use Flasher\Laravel\Config\Config;
|
||||||
|
use Flasher\Laravel\NotifyServiceProvider;
|
||||||
|
use Flasher\Laravel\Storage\Storage;
|
||||||
|
use Flasher\Prime\Filter\DefaultFilter;
|
||||||
|
use Flasher\Prime\Filter\FilterBuilder;
|
||||||
|
use Flasher\Prime\Filter\FilterManager;
|
||||||
|
use Flasher\Prime\Flasher;
|
||||||
|
use Flasher\Prime\Middleware\MiddlewareManager;
|
||||||
|
use Flasher\Prime\Presenter\Adapter\HtmlPresenter;
|
||||||
|
use Flasher\Prime\Presenter\Adapter\JsonPresenter;
|
||||||
|
use Flasher\Prime\Presenter\PresenterManager;
|
||||||
|
use Flasher\Prime\Renderer\RendererManager;
|
||||||
|
use Illuminate\Container\Container;
|
||||||
|
use Illuminate\Foundation\Application;
|
||||||
|
use Illuminate\Support\Facades\Blade;
|
||||||
|
|
||||||
|
class Laravel implements ServiceProviderInterface
|
||||||
|
{
|
||||||
|
protected $app;
|
||||||
|
|
||||||
|
public function __construct(Container $app)
|
||||||
|
{
|
||||||
|
$this->app = $app;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function shouldBeUsed()
|
||||||
|
{
|
||||||
|
return $this->app instanceof Application;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function publishConfig(NotifyServiceProvider $provider)
|
||||||
|
{
|
||||||
|
$source = realpath($raw = __DIR__.'/../../../resources/config/config.php') ?: $raw;
|
||||||
|
|
||||||
|
$provider->publishes(array($source => config_path('notify.php')), 'config');
|
||||||
|
|
||||||
|
$provider->mergeConfigFrom($source, 'notify');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function publishAssets(NotifyServiceProvider $provider)
|
||||||
|
{
|
||||||
|
$provider->publishes(array(__DIR__.'/../../../public' => public_path('vendor/php-flasher/flasher/assets/js')), 'public');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function registerNotifyServices()
|
||||||
|
{
|
||||||
|
$this->app->singleton('notify.config', function (Application $app) {
|
||||||
|
return new Config($app['config'], '.');
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->registerCommonServices();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function registerCommonServices()
|
||||||
|
{
|
||||||
|
$this->app->singleton('notify.producer', function (Application $app) {
|
||||||
|
return new Flasher($app['notify.config']);
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->app->singleton('notify.storage', function (Application $app) {
|
||||||
|
return new Storage($app['session']);
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->app->singleton('notify.filter', function (Application $app) {
|
||||||
|
return new FilterManager($app['notify.config']);
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->app->singleton('notify.renderer', function (Application $app) {
|
||||||
|
return new RendererManager($app['notify.config']);
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->app->singleton('notify.presenter', function (Application $app) {
|
||||||
|
return new PresenterManager();
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->app->singleton('notify.presenter.html', function (Application $app) {
|
||||||
|
return new HtmlPresenter($app['notify.config'], $app['notify.storage'], $app['notify.filter'], $app['notify.renderer']);
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->app->singleton('notify.presenter.json', function (Application $app) {
|
||||||
|
return new JsonPresenter($app['notify.config'], $app['notify.storage'], $app['notify.filter'], $app['notify.renderer']);
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->app->singleton('notify.filter_builder', function (Application $app) {
|
||||||
|
return new FilterBuilder();
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->app->singleton('notify.filter.default', function (Application $app) {
|
||||||
|
return new DefaultFilter($app['notify.filter_builder']);
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->app->singleton('notify.middleware', function (Application $app) {
|
||||||
|
return new MiddlewareManager($app['notify.config']);
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->app->extend('notify.presenter', function (PresenterManager $manager, Container $app) {
|
||||||
|
$manager->addDriver('html', $app['notify.presenter.html']);
|
||||||
|
|
||||||
|
return $manager;
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->app->extend('notify.presenter', function (PresenterManager $manager, Container $app) {
|
||||||
|
$manager->addDriver('json', $app['notify.presenter.json']);
|
||||||
|
|
||||||
|
return $manager;
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->app->extend('notify.filter', function (FilterManager $manager, Container $app) {
|
||||||
|
$manager->addDriver('default', $app['notify.filter.default']);
|
||||||
|
|
||||||
|
return $manager;
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->app->alias('notify.config', 'Flasher\Laravel\Config\Config');
|
||||||
|
$this->app->alias('notify.producer', 'Flasher\Prime\Flasher');
|
||||||
|
$this->app->alias('notify.presenter', 'Flasher\Prime\Presenter\PresenterManager');
|
||||||
|
$this->app->alias('notify.middleware', 'Flasher\Prime\Middleware\MiddlewareManager');
|
||||||
|
$this->app->alias('notify.storage', 'Flasher\Laravel\Storage\Storage');
|
||||||
|
$this->app->alias('notify.filter', 'Flasher\Prime\Filter\FilterManager');
|
||||||
|
$this->app->alias('notify.presenter.html', 'Flasher\Prime\Presenter\Adapter\HtmlPresenter');
|
||||||
|
$this->app->alias('notify.presenter.json', 'Flasher\Prime\Presenter\Adapter\JsonPresenter');
|
||||||
|
$this->app->alias('notify.filter_builder', 'Flasher\Prime\Filter\FilterBuilder');
|
||||||
|
$this->app->alias('notify.filter.default', 'Flasher\Prime\Filter\DefaultFilter');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function registerBladeDirectives()
|
||||||
|
{
|
||||||
|
Blade::directive('notify_render', function ($criteria = null) {
|
||||||
|
return "<?php echo app('notify.presenter.html')->render($criteria); ?>";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Flasher\Laravel\ServiceProvider\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Application;
|
||||||
|
use Illuminate\Support\Facades\Blade;
|
||||||
|
use Flasher\Laravel\Config\Config;
|
||||||
|
use Flasher\Laravel\NotifyServiceProvider;
|
||||||
|
use Flasher\Prime\Middleware\MiddlewareManager;
|
||||||
|
|
||||||
|
final class Laravel4 extends Laravel
|
||||||
|
{
|
||||||
|
public function shouldBeUsed()
|
||||||
|
{
|
||||||
|
return $this->app instanceof Application && 0 === strpos(Application::VERSION, '4.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function publishConfig(NotifyServiceProvider $provider)
|
||||||
|
{
|
||||||
|
$provider->package('php-flasher/flasher-laravel', 'notify', __DIR__.'/../../../resources');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function publishAssets(NotifyServiceProvider $provider)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function registerNotifyServices()
|
||||||
|
{
|
||||||
|
$this->app->singleton('notify.config', function (Application $app) {
|
||||||
|
return new Config($app['config'], '::');
|
||||||
|
});
|
||||||
|
|
||||||
|
$this->registerCommonServices();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function registerBladeDirectives()
|
||||||
|
{
|
||||||
|
Blade::extend(function ($view, $compiler) {
|
||||||
|
$pattern = $compiler->createPlainMatcher('notify_render(.*)');
|
||||||
|
|
||||||
|
return preg_replace($pattern, '$1<?php echo app(\'notify.presenter.html\')->render($2); ?>', $view);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Flasher\Laravel\ServiceProvider\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Application;
|
||||||
|
use Illuminate\Support\Facades\Blade;
|
||||||
|
|
||||||
|
final class Laravel50 extends Laravel
|
||||||
|
{
|
||||||
|
public function shouldBeUsed()
|
||||||
|
{
|
||||||
|
return $this->app instanceof Application && 0 === strpos(Application::VERSION, '5.0');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function registerBladeDirectives()
|
||||||
|
{
|
||||||
|
Blade::extend(function ($view, $compiler) {
|
||||||
|
$pattern = $compiler->createPlainMatcher('notify_render(.*)');
|
||||||
|
|
||||||
|
return preg_replace($pattern, '$1<?php echo app(\'notify.presenter.html\')->render($2); ?>', $view);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Flasher\Laravel\ServiceProvider\Providers;
|
||||||
|
|
||||||
|
use Laravel\Lumen\Application;
|
||||||
|
use Flasher\Laravel\NotifyServiceProvider;
|
||||||
|
|
||||||
|
final class Lumen extends Laravel
|
||||||
|
{
|
||||||
|
public function shouldBeUsed()
|
||||||
|
{
|
||||||
|
return $this->app instanceof Application;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function publishConfig(NotifyServiceProvider $provider)
|
||||||
|
{
|
||||||
|
$source = realpath($raw = __DIR__.'/../../../resources/config/config.php') ?: $raw;
|
||||||
|
|
||||||
|
$this->app->configure('notify');
|
||||||
|
|
||||||
|
$provider->mergeConfigFrom($source, 'notify');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function registerNotifyServices()
|
||||||
|
{
|
||||||
|
$this->app->register('\Illuminate\Session\SessionServiceProvider');
|
||||||
|
$this->app->configure('session');
|
||||||
|
|
||||||
|
parent::registerNotifyServices();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Flasher\Laravel\ServiceProvider\Providers;
|
||||||
|
|
||||||
|
use Flasher\Laravel\NotifyServiceProvider;
|
||||||
|
|
||||||
|
interface ServiceProviderInterface
|
||||||
|
{
|
||||||
|
public function shouldBeUsed();
|
||||||
|
|
||||||
|
public function publishConfig(NotifyServiceProvider $provider);
|
||||||
|
|
||||||
|
public function publishAssets(NotifyServiceProvider $provider);
|
||||||
|
|
||||||
|
public function registerNotifyServices();
|
||||||
|
|
||||||
|
public function registerBladeDirectives();
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Flasher\Laravel\ServiceProvider;
|
||||||
|
|
||||||
|
use Flasher\Laravel\NotifyServiceProvider;
|
||||||
|
use Flasher\Laravel\ServiceProvider\Providers\ServiceProviderInterface;
|
||||||
|
|
||||||
|
final class ServiceProviderManager
|
||||||
|
{
|
||||||
|
private $provider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ServiceProviderInterface[]
|
||||||
|
*/
|
||||||
|
private $providers = array(
|
||||||
|
'Flasher\Laravel\ServiceProvider\Providers\Laravel4',
|
||||||
|
'Flasher\Laravel\ServiceProvider\Providers\Laravel50',
|
||||||
|
'Flasher\Laravel\ServiceProvider\Providers\Laravel',
|
||||||
|
'Flasher\Laravel\ServiceProvider\Providers\Lumen',
|
||||||
|
);
|
||||||
|
|
||||||
|
private $notifyServiceProvider;
|
||||||
|
|
||||||
|
public function __construct(NotifyServiceProvider $notifyServiceProvider)
|
||||||
|
{
|
||||||
|
$this->notifyServiceProvider = $notifyServiceProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
$provider = $this->resolveServiceProvider();
|
||||||
|
|
||||||
|
$provider->publishConfig($this->notifyServiceProvider);
|
||||||
|
$provider->publishAssets($this->notifyServiceProvider);
|
||||||
|
$provider->registerBladeDirectives();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
$provider = $this->resolveServiceProvider();
|
||||||
|
$provider->registerNotifyServices();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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.');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Flasher\Laravel\Storage;
|
||||||
|
|
||||||
|
use Flasher\Prime\Envelope;
|
||||||
|
use Flasher\Prime\Stamp\CreatedAtStamp;
|
||||||
|
use Flasher\Prime\Stamp\LifeStamp;
|
||||||
|
use Flasher\Prime\Stamp\UuidStamp;
|
||||||
|
use Flasher\Prime\Storage\StorageInterface;
|
||||||
|
|
||||||
|
final class Storage implements StorageInterface
|
||||||
|
{
|
||||||
|
const ENVELOPES_NAMESPACE = 'notify::envelopes';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \Illuminate\Session\SessionManager|\Illuminate\Session\Store
|
||||||
|
*/
|
||||||
|
private $session;
|
||||||
|
|
||||||
|
public function __construct($session)
|
||||||
|
{
|
||||||
|
$this->session = $session;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get()
|
||||||
|
{
|
||||||
|
return $this->session->get(self::ENVELOPES_NAMESPACE, array());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function add(Envelope $envelope)
|
||||||
|
{
|
||||||
|
if (null === $envelope->get('Flasher\Prime\Stamp\UuidStamp')) {
|
||||||
|
$envelope->withStamp(new UuidStamp());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null === $envelope->get('Flasher\Prime\Stamp\LifeStamp')) {
|
||||||
|
$envelope->withStamp(new LifeStamp(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null === $envelope->get('Flasher\Prime\Stamp\CreatedAtStamp')) {
|
||||||
|
$envelope->withStamp(new CreatedAtStamp());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$envelopes = $this->get();
|
||||||
|
$envelopes[] = $envelope;
|
||||||
|
|
||||||
|
$this->session->put(self::ENVELOPES_NAMESPACE, $envelopes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Flasher\Prime\Envelope[] $envelopes
|
||||||
|
*/
|
||||||
|
public function flush($envelopes)
|
||||||
|
{
|
||||||
|
$envelopesMap = array();
|
||||||
|
|
||||||
|
foreach ($envelopes as $envelope) {
|
||||||
|
$life = $envelope->get('Flasher\Prime\Stamp\LifeStamp')->getLife();
|
||||||
|
$uuid = $envelope->get('Flasher\Prime\Stamp\UuidStamp')->getUuid();
|
||||||
|
|
||||||
|
$envelopesMap[$uuid] = $life;
|
||||||
|
}
|
||||||
|
|
||||||
|
$store = array();
|
||||||
|
|
||||||
|
foreach ($this->session->get(self::ENVELOPES_NAMESPACE, array()) as $envelope) {
|
||||||
|
$uuid = $envelope->get('Flasher\Prime\Stamp\UuidStamp')->getUuid();
|
||||||
|
|
||||||
|
if(isset($envelopesMap[$uuid])) {
|
||||||
|
$life = $envelopesMap[$uuid] - 1;
|
||||||
|
|
||||||
|
if ($life <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$envelope->with(new LifeStamp($life));
|
||||||
|
}
|
||||||
|
|
||||||
|
$store[] = $envelope;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->session->put(self::ENVELOPES_NAMESPACE, $store);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Flasher\Laravel\Tests\Config;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Application;
|
||||||
|
use Flasher\Laravel\Config\Config;
|
||||||
|
use Flasher\Laravel\Tests\TestCase;
|
||||||
|
|
||||||
|
final class ConfigTest extends TestCase
|
||||||
|
{
|
||||||
|
public function test_simple_config()
|
||||||
|
{
|
||||||
|
$separator = $this->isLaravel4() ? '::' : '.';
|
||||||
|
$config = new Config($this->app->make('config'), $separator);
|
||||||
|
|
||||||
|
$this->assertEquals('toastr', $config->get('default'));
|
||||||
|
$this->assertSame(array(), $config->get('adapters', array()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function isLaravel4()
|
||||||
|
{
|
||||||
|
return 0 === strpos(Application::VERSION, '4.');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Flasher\Laravel\Tests;
|
||||||
|
|
||||||
|
use Illuminate\View\Compilers\BladeCompiler;
|
||||||
|
|
||||||
|
class NotifyServiceProviderTest extends TestCase
|
||||||
|
{
|
||||||
|
public function test_notify_service_exists()
|
||||||
|
{
|
||||||
|
$this->assertTrue($this->app->bound('notify.producer'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_notify_manager_get_config()
|
||||||
|
{
|
||||||
|
$notify = $this->app->make('notify.producer');
|
||||||
|
|
||||||
|
$reflection = new \ReflectionClass(get_class($notify));
|
||||||
|
$config = $reflection->getProperty('config');
|
||||||
|
$config->setAccessible(true);
|
||||||
|
|
||||||
|
$this->assertInstanceOf('Flasher\Prime\Config\ConfigInterface', $config->getValue($notify));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_blade_directive()
|
||||||
|
{
|
||||||
|
/** @var BladeCompiler $blade */
|
||||||
|
$blade = $this->app->make('view')->getEngineResolver()->resolve('blade')->getCompiler();
|
||||||
|
|
||||||
|
$this->assertEquals("<?php echo app('notify.presenter.html')->render(); ?>", $blade->compileString('@notify_render'));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Flasher\Laravel\Tests\Storage;
|
||||||
|
|
||||||
|
use Flasher\Laravel\Storage\Storage;
|
||||||
|
use Flasher\Laravel\Tests\TestCase;
|
||||||
|
use Flasher\Prime\Envelope;
|
||||||
|
use Flasher\Prime\Notification\Notification;
|
||||||
|
|
||||||
|
final class StorageTest extends TestCase
|
||||||
|
{
|
||||||
|
public function test_simple()
|
||||||
|
{
|
||||||
|
$session = new Storage($this->app->make('session'));
|
||||||
|
|
||||||
|
$envelope = new Envelope(new Notification('success', 'message'));
|
||||||
|
$session->add($envelope);
|
||||||
|
|
||||||
|
$this->assertEquals(array($envelope), $session->get());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Flasher\Laravel\Tests;
|
||||||
|
|
||||||
|
use Orchestra\Testbench\TestCase as Orchestra;
|
||||||
|
|
||||||
|
class TestCase extends Orchestra
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param $app
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getPackageProviders($app = null)
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'Flasher\Laravel\NotifyServiceProvider',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Illuminate\Foundation\Application $app
|
||||||
|
*/
|
||||||
|
protected function getEnvironmentSetUp($app)
|
||||||
|
{
|
||||||
|
$app['config']->set('session.driver', 'array');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
{
|
||||||
|
"name": "php-flasher/flasher-laravel",
|
||||||
|
"description": "Laravel Flasher package for php-flasher/flasher",
|
||||||
|
"keywords": [
|
||||||
|
"yoeunes",
|
||||||
|
"notify",
|
||||||
|
"php",
|
||||||
|
"laravel",
|
||||||
|
"symfony",
|
||||||
|
"Lumen",
|
||||||
|
"notifications",
|
||||||
|
"messages",
|
||||||
|
"alerts",
|
||||||
|
"pnotify",
|
||||||
|
"toastr ",
|
||||||
|
"bundle",
|
||||||
|
"flex"
|
||||||
|
],
|
||||||
|
"homepage": "https://github.com/php-flasher/flasher-laravel",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Younes Khoubza",
|
||||||
|
"email": "younes.khoubza@gmail.com",
|
||||||
|
"homepage": "https://github.com/yoeunes",
|
||||||
|
"role": "Developer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3",
|
||||||
|
"illuminate/support": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0",
|
||||||
|
"php-flasher/flasher": "^1.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "^4.8 || ^5.7 || ^6.0 || ^7.0 || ^8.3 || ^9.0",
|
||||||
|
"orchestra/testbench": "^2.0 || ^3.0 || ^4.0 || ^5.0 || ^6.0"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Flasher\\Laravel\\": "src/"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"helpers.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"autoload-dev": {
|
||||||
|
"psr-4": {
|
||||||
|
"Flasher\\Laravel\\Tests\\": "tests/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"providers": [
|
||||||
|
"Flasher\\Laravel\\NotifyServiceProvider"
|
||||||
|
],
|
||||||
|
"aliases": {
|
||||||
|
"Flasher": "Flasher\\Laravel\\Facades\\Flasher"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"sort-packages": true
|
||||||
|
},
|
||||||
|
"minimum-stability": "dev",
|
||||||
|
"prefer-stable": true
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (!function_exists('notify')) {
|
||||||
|
/**
|
||||||
|
* @param string $message
|
||||||
|
* @param string $type
|
||||||
|
* @param string $title
|
||||||
|
* @param array $options
|
||||||
|
* @param array $stamps
|
||||||
|
*
|
||||||
|
* @return \Flasher\Prime\Flasher
|
||||||
|
*/
|
||||||
|
function notify($message = null, $type = 'success', $title = '', array $options = array(), array $stamps = array())
|
||||||
|
{
|
||||||
|
if (is_null($message) && 0 === func_num_args()) {
|
||||||
|
return app('notify.producer');
|
||||||
|
}
|
||||||
|
|
||||||
|
return app('notify.producer')->render($type, $message, $title, $options, $stamps);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<phpunit bootstrap="vendor/autoload.php"
|
||||||
|
backupGlobals="false"
|
||||||
|
backupStaticAttributes="false"
|
||||||
|
colors="true"
|
||||||
|
verbose="true"
|
||||||
|
convertErrorsToExceptions="true"
|
||||||
|
convertNoticesToExceptions="true"
|
||||||
|
convertWarningsToExceptions="true"
|
||||||
|
processIsolation="false"
|
||||||
|
stopOnFailure="true">
|
||||||
|
<testsuites>
|
||||||
|
<testsuite name="Flasher Test Suite">
|
||||||
|
<directory>tests</directory>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
|
<filter>
|
||||||
|
<whitelist>
|
||||||
|
<directory suffix=".php">src/</directory>
|
||||||
|
</whitelist>
|
||||||
|
</filter>
|
||||||
|
</phpunit>
|
||||||
Reference in New Issue
Block a user