The Observer Component
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
docs
src
tests
.gitattributes
.gitignore
.scrutinizer.yml
.travis.yml
LICENSE
README.md
composer.json
phpunit.xml.dist

README.md

Observer

Build Status Code Coverage Scrutinizer Code Quality SensioLabsInsight

The Observer Component.

Example

<?php

use miBadger\Observer\ObserverInterface;
use miBadger\Observer\SubjectInterface;
use miBadger\Observer\SubjectTrait;

/**
 * The observer class.
 */
class Observer implements ObserverInterface
{
	/**
	 * {@inheritdoc}
	 */
	public function update(SubjectInterface $subject, $arguments = null)
	{
		echo 'test';
	}
}

/**
 * The subject class.
 */
class Subject implement SubjectInterface
{
	use SubjectTrait;
}
<?php

/**
 * Create a new subject.
 */
$subject = new Subject();

/**
 * Create a new observer.
 */
$observer = new Observer()

/**
 * Attach observer.
 */
$subject->attach($observer);

/**
 * Notify the attached observers.
 */
$subject->notify();