Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
aaemnnosttv committed Jun 11, 2016
1 parent 76ebb07 commit b985cbd
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 44 deletions.
72 changes: 49 additions & 23 deletions src/Event/Hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class Hook
*
* @param string $handle action or filter handle
* @param int $priority
* @return static instance
*
* @return static
*/
public static function on($handle, $priority = 10)
{
Expand All @@ -33,6 +34,7 @@ public static function on($handle, $priority = 10)

/**
* Create a new Hook instance
*
* @param string $handle action or filter handle
* @param int $priority
*/
Expand All @@ -43,8 +45,11 @@ public function __construct($handle, $priority = 10)
}

/**
* [setCallback description]
* @param callable $callback [description]
* Set the callback to be invoked by the action or filter
*
* @param callable $callback
*
* @return $this
*/
public function setCallback(callable $callback)
{
Expand All @@ -55,8 +60,11 @@ public function setCallback(callable $callback)
}

/**
* Set the hook in WP
* @return [type] [description]
* Set the hook in WordPress
*
* Both actions and filters are registered as filters.
*
* @return $this
*/
public function listen()
{
Expand All @@ -66,8 +74,9 @@ public function listen()
}

/**
* Unset the hook in WP
* @return [type] [description]
* Unset the hook in WordPress
*
* @return $this
*/
public function remove()
{
Expand All @@ -77,8 +86,9 @@ public function remove()
}

/**
* [mediateCallback description]
* @return [type] [description]
* Control invocation of the callback
*
* @return mixed callback returned value
*/
public function mediateCallback($given = null)
{
Expand All @@ -89,6 +99,13 @@ public function mediateCallback($given = null)
return $this->invokeCallback(func_get_args());
}

/**
* Whether or not the callback should be invoked
*
* @param array $args all arguments passed to the callback
*
* @return bool
*/
public function shouldInvoke(array $args)
{
if ($this->hasExceededIterations()) {
Expand All @@ -99,9 +116,11 @@ public function shouldInvoke(array $args)
}

/**
* [invokeCallback description]
* @param [type] $arguments [description]
* @return [type] [description]
* Call the callback
*
* @param array $arguments the arguments expected by the callback
*
* @return mixed returned output from the callback
*/
protected function invokeCallback($arguments)
{
Expand All @@ -113,8 +132,9 @@ protected function invokeCallback($arguments)
}

/**
* [once description]
* @return [type] [description]
* Set the callback to only be invoked one time
*
* @return $this
*/
public function once()
{
Expand All @@ -124,9 +144,11 @@ public function once()
}

/**
* [onlyXtimes description]
* @param [type] $times [description]
* @return [type] [description]
* Set the callback to only be invoked the given number of times
*
* @param int $times maimum iterations of invocations to allow
*
* @return $this
*/
public function onlyXtimes($times)
{
Expand All @@ -137,7 +159,8 @@ public function onlyXtimes($times)

/**
* Prevent the callback from being triggered again
* @return [type] [description]
*
* @return $this
*/
public function bypass()
{
Expand All @@ -147,9 +170,11 @@ public function bypass()
}

/**
* [withPriority description]
* @param [type] $priority [description]
* @return [type] [description]
* Set the priority the callback should be registered with
*
* @param string|int $priority
*
* @return $this
*/
public function withPriority($priority)
{
Expand All @@ -163,8 +188,9 @@ public function withPriority($priority)
}

/**
* [hasExceededIterations description]
* @return boolean [description]
* Whether or not the callback has reached the limit of allowed invocations
*
* @return boolean true for limit reached, otherwise false
*/
protected function hasExceededIterations()
{
Expand Down
7 changes: 4 additions & 3 deletions src/Meta/Meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public function all()
* Set the meta value
*
* @param mixed $value
* @param string $prev_value [description]
* @param string $prev_value
*
* @return bool True on success, false on failure
*/
public function set($value, $prev_value = '')
Expand All @@ -64,7 +65,7 @@ public function set($value, $prev_value = '')
* Add metadata for the specified object
*
* @param mixed $value The value to add
* @param [type] $unique [description]
* @param bool $unique
*
* @return int|false The meta ID on success, false on failure.
*/
Expand Down Expand Up @@ -103,7 +104,7 @@ public function exists()

/**
* Get the object_id
*
*
* @return int|string
*/
public function getObjectId()
Expand Down
35 changes: 21 additions & 14 deletions src/Post/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ abstract class Model


/**
* [__construct description]
* @param WP_Post $post [description]
* Create a new instance
*
* @param WP_Post $post Post object to model
*/
public function __construct(WP_Post $post = null)
{
Expand All @@ -59,7 +60,7 @@ public static function fromWpPost(WP_Post $post)
/**
* Make new instance from a Post with the given ID
*
* @param int|string $id [description]
* @param int|string $id Post ID of post to create the instance from
*
* @return static
*/
Expand Down Expand Up @@ -115,8 +116,9 @@ public static function fromGlobal()
/**
* Create a new post of the model's type
*
* @param [type] $attributes [description]
* @return [type] [description]
* @param array $attributes
*
* @return static
*/
public static function create($attributes = [])
{
Expand All @@ -133,7 +135,7 @@ public static function create($attributes = [])
/**
* Meta API for this post
*
* @param string $key [description]
* @param string $key Meta key to retreive or empty to retreive all.
*
* @return object
*/
Expand All @@ -153,7 +155,7 @@ public function meta($key = '')
*
* If trash is disabled, the post or page is permanently deleted.
*
* @return false|array|WP_Post|null Post data array, otherwise false.
* @return $this
*/
public function trash()
{
Expand All @@ -167,7 +169,7 @@ public function trash()
/**
* Restore a post or page from the Trash
*
* @return WP_Post|false WP_Post object. False on failure.
* @return $this
*/
public function untrash()
{
Expand All @@ -185,7 +187,7 @@ public function untrash()
* tied to it is deleted also. This includes comments, post meta fields,
* and terms associated with the post.
*
* @return [type] [description]
* @return $this
*/
public function delete()
{
Expand All @@ -199,7 +201,7 @@ public function delete()
/**
* Refresh the post object from cache/database
*
* @return static
* @return $this
*/
public function refresh()
{
Expand All @@ -211,7 +213,7 @@ public function refresh()
/**
* Update the post in the database
*
* @return [type] [description]
* @return $this
*/
public function save()
{
Expand Down Expand Up @@ -247,6 +249,7 @@ public function newQuery()

/**
* Create a new query builder instance for this model type.
*
* @return Builder
*/
public static function query()
Expand All @@ -256,7 +259,9 @@ public static function query()

/**
* Magic getter
*
* @param string $property
*
* @return mixed
*/
public function __get($property)
Expand All @@ -273,6 +278,7 @@ public function __get($property)

/**
* Magic setter
*
* @param string $property
* @param mixed $value
*/
Expand All @@ -288,7 +294,7 @@ public function __set($property, $value)
*
* Proxies calls to direct method calls on a new instance
*
* @param $method
* @param string $method
* @param array $arguments
*
* @return mixed
Expand All @@ -301,8 +307,9 @@ public static function __callStatic($method, array $arguments)
/**
* Handle dynamic method calls into the model.
*
* @param string $method
* @param array $arguments
* @param string $method
* @param array $arguments
*
* @return mixed
*/
public function __call($method, $arguments)
Expand Down
12 changes: 8 additions & 4 deletions src/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ class Builder
{
/**
* WP_Query instance
*
* @var WP_Query
*/
protected $query;

/**
* Post Model instance
*
* @var Model
*/
protected $model;
Expand Down Expand Up @@ -47,9 +49,11 @@ public function limit($limit)
}

/**
* [order description]
* @param [type] $order [description]
* @return [type] [description]
* Set the order for the query
*
* @param string $order
*
* @return $this
*/
public function order($order)
{
Expand All @@ -62,7 +66,7 @@ public function order($order)
* Query by post status
*
* @param string|array $status the post status or stati to match
*
*
* @return $this
*/
public function whereStatus($status)
Expand Down

0 comments on commit b985cbd

Please sign in to comment.