Skip to content

Commit

Permalink
Init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
PeratX committed Jan 24, 2017
0 parents commit a5fd251
Show file tree
Hide file tree
Showing 57 changed files with 5,559 additions and 0 deletions.
619 changes: 619 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
SimpleGUI
===================

__The GUI SDK based on php-gui for SimpleFramework(CLI)__

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

Introduction
-------------
With this SDK, you can create a visual window quickly and easily.

Get SimpleGUI
-------------
__[Releases](https://github.com/PeratX/SimpleGUI/releases)__
10 changes: 10 additions & 0 deletions info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "SimpleGUI",
"version": "1.0.0",
"api": 2,
"description": "The GUI SDK based on php-gui for SimpleFramework.",
"author": "PeratX",
"main": "SimpleGUI\\Main",
"order": 0,
"website": "https://github.com/PeratX/SimpleGUI"
}
Binary file added resources/phpgui-x86_64-win64.exe
Binary file not shown.
17 changes: 17 additions & 0 deletions src/Evenement/EventEmitter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

/*
* This file is part of Evenement.
*
* (c) Igor Wiedler <igor@wiedler.ch>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Evenement;

class EventEmitter implements EventEmitterInterface
{
use EventEmitterTrait;
}
22 changes: 22 additions & 0 deletions src/Evenement/EventEmitterInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/*
* This file is part of Evenement.
*
* (c) Igor Wiedler <igor@wiedler.ch>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Evenement;

interface EventEmitterInterface
{
public function on($event, callable $listener);
public function once($event, callable $listener);
public function removeListener($event, callable $listener);
public function removeAllListeners($event = null);
public function listeners($event);
public function emit($event, array $arguments = []);
}
68 changes: 68 additions & 0 deletions src/Evenement/EventEmitterTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

/*
* This file is part of Evenement.
*
* (c) Igor Wiedler <igor@wiedler.ch>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Evenement;

trait EventEmitterTrait
{
protected $listeners = [];

public function on($event, callable $listener)
{
if (!isset($this->listeners[$event])) {
$this->listeners[$event] = [];
}

$this->listeners[$event][] = $listener;
}

public function once($event, callable $listener)
{
$onceListener = function () use (&$onceListener, $event, $listener) {
$this->removeListener($event, $onceListener);

call_user_func_array($listener, func_get_args());
};

$this->on($event, $onceListener);
}

public function removeListener($event, callable $listener)
{
if (isset($this->listeners[$event])) {
$index = array_search($listener, $this->listeners[$event], true);
if (false !== $index) {
unset($this->listeners[$event][$index]);
}
}
}

public function removeAllListeners($event = null)
{
if ($event !== null) {
unset($this->listeners[$event]);
} else {
$this->listeners = [];
}
}

public function listeners($event)
{
return isset($this->listeners[$event]) ? $this->listeners[$event] : [];
}

public function emit($event, array $arguments = [])
{
foreach ($this->listeners($event) as $listener) {
call_user_func_array($listener, $arguments);
}
}
}
Loading

0 comments on commit a5fd251

Please sign in to comment.