Skip to content

Commit b38bbb8

Browse files
committed
Updated to 1.0.7 version
1 parent 5ae0329 commit b38bbb8

File tree

6 files changed

+79
-3
lines changed

6 files changed

+79
-3
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# CHANGELOG
22

3+
## 1.0.7 - 2017-10-18
4+
5+
* Added `Josantonius\Hook\Hook::isAction()` method.
6+
7+
* Added `Josantonius\Hook\Test\HookTest::testIsAction()` method.
8+
* Added `Josantonius\Hook\Test\HookTest::testIsNotAction()` method.
9+
310
## 1.0.6 - 2017-09-13
411

512
* Unit tests supported by `PHPUnit` were added.

README-ES.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@ Hook::doAction($tag, $args, $remove);
110110
Hook::current();
111111
```
112112

113+
**isAction()**
114+
```php
115+
Hook::isAction($tag);
116+
```
117+
118+
| Atttribute | Description | Type | Required | Default
119+
| --- | --- | --- | --- | --- |
120+
| $tag | Action hook name | string | Yes | |
121+
113122
### Uso
114123

115124
Ejemplo de uso para esta biblioteca:

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,16 @@ Hook::doAction($tag, $args, $remove);
109109
```php
110110
Hook::current();
111111
```
112-
112+
113+
**isAction()**
114+
```php
115+
Hook::isAction($tag);
116+
```
117+
118+
| Atttribute | Description | Type | Required | Default
119+
| --- | --- | --- | --- | --- |
120+
| $tag | Action hook name | string | Yes | |
121+
113122
### Usage
114123

115124
Example of use for this library:

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "josantonius/hook",
3-
"version": "1.0.6",
3+
"version": "1.0.7",
44
"type": "library",
55
"description": "Library for handling hooks.",
66
"keywords": [

src/Hook/Hook.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,23 @@ public static function current() {
213213

214214
return self::$current;
215215
}
216-
216+
217+
/**
218+
* Returns the current action hook.
219+
*
220+
* @since 1.0.7
221+
*
222+
* @param string $tag → action hook name
223+
*
224+
* @return string|false → current action hook
225+
*/
226+
public static function isAction($tag) {
227+
228+
$that = self::getInstance(self::$id);
229+
230+
return (isset($that->callbacks[$tag]));
231+
}
232+
217233
/**
218234
* Run action hook.
219235
*

tests/Hook/Test/HookTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,41 @@ public function testAddMultipleActionsWithCustomSingletonMethod() {
137137
);
138138
}
139139

140+
/**
141+
* Check if is action.
142+
*
143+
* @since 1.0.7
144+
*
145+
* @return void
146+
*/
147+
public function testIsAction() {
148+
149+
$this->assertTrue(
150+
151+
Hook::isAction('meta')
152+
);
153+
154+
$this->assertTrue(
155+
156+
Hook::isAction('form')
157+
);
158+
}
159+
160+
/**
161+
* Check if isn`t action.
162+
*
163+
* @since 1.0.7
164+
*
165+
* @return void
166+
*/
167+
public function testIsNotAction() {
168+
169+
$this->assertFalse(
170+
171+
Hook::isAction('unknown')
172+
);
173+
}
174+
140175
/**
141176
* Execute action hooks.
142177
*

0 commit comments

Comments
 (0)