<commit_before># GigaFoxWeb Notifier

Thank you for your interest in this product. I hope you will enjoy it. [gigafoxweb.com](http://gigafoxweb.com).

The main task of Notifier is to register system notifications in one place and show them when and where they need.

# Installation
```
composer require gigafoxweb/notifier
```

If you installed package by composer you just need to :

```php
require_once __DIR__ . '/vendor/autoload.php';
```

else :

```php
require_once '/src/Notifier/Notification.php';
require_once '/src/Notifier/INotifier.php';
require_once '/src/Notifier/Notifier.php';
require_once '/src/Notifier/Helper.php';
require_once '/src/Notifier/SessionNotifier.php';
require_once '/src/Notifier/MemoryNotifier.php';
require_once '/src/Notifier/NotificationFilter.php';
require_once '/src/Notifier/InlineNotificationFilter.php';
require_once '/src/Notifier/NotifierException.php';
require_once '/src/Notifier/SessionNotifierException.php';
```

#Notification
Notifications are GigaFoxWeb\Notifier\Notification class objects or extending it.

#Notifier
Notifiers is static classes extends from GigaFoxWeb\Notifier\Notifier and implements INotifier interface.
It must have 3 required static methods: Notifier::setNotification, Notifier::getNotification, Notifier::removeNotification.
This static classes you will use in your app.
By default package have 2 notifiers MemoryNotifier and SessionNotifier.

You can set notifications to notifier by array || object || callable function || string.
```
MemoryNotifier::setNotification('notification 1 key', new Notification('message'));
MemoryNotifier::setNotification('notification 2 key', 'message');
MemoryNotifier::setNotification('notification 3 key', ['you can do anything you want in this notifier', [
	'show' => true
]]);
MemoryNotifier::setNotification('notification 4 key', function() {
	return new Notification('message');
});
```
#NotificationFilter
NotificationFilters are objects extending GigaFoxWeb\Notifider\NotificationFilter. 
It help you to filtrate notifications when you wanna display/get it from notifier.

NotificationFilters can be created automatically in notifier from callable param || array.

Show all notifications by some search params and filtrate it example:
```
$filters = [
	function(Notification $notification) {
		$notification->setMessage($notification->getMessage() . ' php -v : '. phpversion());
	},
	[
		'function' => function(Notification $notification) {
			$notification->setMessage("<div class='alert alert-{$notification->getParam('class')}'>{$notification->getMessage()}</div>");
		},
		'search' => ['params' => ['class']]
	],
];

MemoryNotifier::showNotificationsBy(['prefix' => 'my', 'params' => [['show', true]]], $filters);
```

#Simple application example :

```
<?php
use GigaFoxWeb\Notifier\MemoryNotifier;
use GigaFoxWeb\Notifier\SessionNotifier;
use GigaFoxWeb\Notifier\Notification;

require_once '/src/Notifier/Notification.php';
require_once '/src/Notifier/INotifier.php';<commit_msg>change readmy.md<commit_after># GigaFoxWeb Notifier

Thank you for your interest in this product. I hope you will enjoy it. [gigafoxweb.com](http://gigafoxweb.com).

The main task of Notifier is to register system notifications in one place and show them when and where they need.

# Installation
```
composer require gigafoxweb/notifier
```

If you installed package by composer you just need to :

```php
require_once __DIR__ . '/vendor/autoload.php';
```

else :

```php
require_once '/src/Notifier/Notification.php';
require_once '/src/Notifier/INotifier.php';
require_once '/src/Notifier/Notifier.php';
require_once '/src/Notifier/Helper.php';
require_once '/src/Notifier/SessionNotifier.php';
require_once '/src/Notifier/MemoryNotifier.php';
require_once '/src/Notifier/NotificationFilter.php';
require_once '/src/Notifier/InlineNotificationFilter.php';
require_once '/src/Notifier/NotifierException.php';
require_once '/src/Notifier/SessionNotifierException.php';
```

#Notification
Notifications are GigaFoxWeb\Notifier\Notification class objects or extending it.

#Notifier
Notifiers is static classes extends from GigaFoxWeb\Notifier\Notifier and implements INotifier interface.
It must have 3 required static methods: Notifier::setNotification, Notifier::getNotification, Notifier::removeNotification.
This static classes you will use in your app.
By default package have 2 notifiers MemoryNotifier and SessionNotifier.

You can set notifications to notifier by array || object || callable function || string.
```php
MemoryNotifier::setNotification('notification 1 key', new Notification('message'));
MemoryNotifier::setNotification('notification 2 key', 'message');
MemoryNotifier::setNotification('notification 3 key', ['you can do anything you want in this notifier', [
	'show' => true
]]);
MemoryNotifier::setNotification('notification 4 key', function() {
	return new Notification('message');
});
```
#NotificationFilter
NotificationFilters are objects extending GigaFoxWeb\Notifider\NotificationFilter. 
It help you to filtrate notifications when you wanna display/get it from notifier.

NotificationFilters can be created automatically in notifier from callable param || array.

Show all notifications by some search params and filtrate it example:
```php
$filters = [
	function(Notification $notification) {
		$notification->setMessage($notification->getMessage() . ' php -v : '. phpversion());
	},
	[
		'function' => function(Notification $notification) {
			$notification->setMessage("<div class='alert alert-{$notification->getParam('class')}'>{$notification->getMessage()}</div>");
		},
		'search' => ['params' => ['class']]
	],
];

MemoryNotifier::showNotificationsBy(['prefix' => 'my', 'params' => [['show', true]]], $filters);
```

#Simple application example :

```php
<?php
use GigaFoxWeb\Notifier\MemoryNotifier;
use GigaFoxWeb\Notifier\SessionNotifier;
use GigaFoxWeb\Notifier\Notification;

require_once '/src/Notifier/Notification.php';
require_once '/src/Notifier/INotifier.php';
{'fraction_non_alphanumeric': 0.12325349301397205, 'fraction_numerical': 0.001996007984031936, 'mean_word_length': 6.235860409145608, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1932334', 'n_tokens_mistral': 1734, 'n_tokens_neox': 1671, 'n_words': 499}