Skip to content

Commit

Permalink
Updated to 1.0.7 version
Browse files Browse the repository at this point in the history
  • Loading branch information
josantonius committed Oct 18, 2017
1 parent 5ae0329 commit b38bbb8
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# CHANGELOG

## 1.0.7 - 2017-10-18

* Added `Josantonius\Hook\Hook::isAction()` method.

* Added `Josantonius\Hook\Test\HookTest::testIsAction()` method.
* Added `Josantonius\Hook\Test\HookTest::testIsNotAction()` method.

## 1.0.6 - 2017-09-13

* Unit tests supported by `PHPUnit` were added.
Expand Down
9 changes: 9 additions & 0 deletions README-ES.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ Hook::doAction($tag, $args, $remove);
Hook::current();
```

**isAction()**
```php
Hook::isAction($tag);
```

| Atttribute | Description | Type | Required | Default
| --- | --- | --- | --- | --- |
| $tag | Action hook name | string | Yes | |

### Uso

Ejemplo de uso para esta biblioteca:
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,16 @@ Hook::doAction($tag, $args, $remove);
```php
Hook::current();
```


**isAction()**
```php
Hook::isAction($tag);
```

| Atttribute | Description | Type | Required | Default
| --- | --- | --- | --- | --- |
| $tag | Action hook name | string | Yes | |

### Usage

Example of use for this library:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "josantonius/hook",
"version": "1.0.6",
"version": "1.0.7",
"type": "library",
"description": "Library for handling hooks.",
"keywords": [
Expand Down
18 changes: 17 additions & 1 deletion src/Hook/Hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,23 @@ public static function current() {

return self::$current;
}


/**
* Returns the current action hook.
*
* @since 1.0.7
*
* @param string $tag → action hook name
*
* @return string|false → current action hook
*/
public static function isAction($tag) {

$that = self::getInstance(self::$id);

return (isset($that->callbacks[$tag]));
}

/**
* Run action hook.
*
Expand Down
35 changes: 35 additions & 0 deletions tests/Hook/Test/HookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,41 @@ public function testAddMultipleActionsWithCustomSingletonMethod() {
);
}

/**
* Check if is action.
*
* @since 1.0.7
*
* @return void
*/
public function testIsAction() {

$this->assertTrue(

Hook::isAction('meta')
);

$this->assertTrue(

Hook::isAction('form')
);
}

/**
* Check if isn`t action.
*
* @since 1.0.7
*
* @return void
*/
public function testIsNotAction() {

$this->assertFalse(

Hook::isAction('unknown')
);
}

/**
* Execute action hooks.
*
Expand Down

0 comments on commit b38bbb8

Please sign in to comment.