Skip to content

Commit

Permalink
docblocks
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
aaemnnosttv committed Jun 21, 2016
1 parent 79c73b2 commit a9d1137
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 54 deletions.
80 changes: 51 additions & 29 deletions src/Event/Hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,42 @@

class Hook
{
/**
* The action or filter handle attached to.
* @var string
*/
protected $handle;

/**
* The callback object holding the target callable.
* @var Callback
*/
protected $callback;

/**
* The number of parameters defined in the callback's signature.
* @var int
*/
protected $callbackParamCount;

/**
* The action or filter priority the callback is registered on.
* @var mixed
*/
protected $priority;

/**
* The number of times the callback has been invoked.
* @var int
*/
protected $iterations;

/**
* The maximum number of iterations allowed for the callback to be invoked.
* @var int
*/
protected $maxIterations;


/**
* Create a new Hook instance
* Create a new Hook instance.
*
* @param string $handle action or filter handle
* @param string $handle Action or filter handle
* @param int $priority
*
* @return static
Expand All @@ -33,9 +52,9 @@ public static function on($handle, $priority = 10)
}

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

/**
* Set the callback to be invoked by the action or filter
* Set the callback to be invoked by the action or filter.
*
* @param callable $callback
* @param callable $callback The callback to be invoked
*
* @return $this
*/
Expand All @@ -60,7 +79,7 @@ public function setCallback(callable $callback)
}

/**
* Set the hook in WordPress
* Set the hook in WordPress.
*
* Both actions and filters are registered as filters.
*
Expand All @@ -74,7 +93,7 @@ public function listen()
}

/**
* Unset the hook in WordPress
* Unset the hook in WordPress.
*
* @return $this
*/
Expand All @@ -86,9 +105,12 @@ public function remove()
}

/**
* Control invocation of the callback
* Control invocation of the callback.
*
* @param $given The first argument passed to the callback.
* Needed to return for filters.
*
* @return mixed callback returned value
* @return mixed Returned value from Callback
*/
public function mediateCallback($given = null)
{
Expand All @@ -100,13 +122,13 @@ public function mediateCallback($given = null)
}

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

/**
* Call the callback
* Call the callback.
*
* @param array $arguments the arguments expected by the callback
* @param array $arguments All arguments passed to the callback
*
* @return mixed returned output from the callback
* @return mixed The value returned from the callback
*/
protected function invokeCallback($arguments)
{
Expand All @@ -132,7 +154,7 @@ protected function invokeCallback($arguments)
}

/**
* Set the callback to only be invoked one time
* Set the callback to only be invokable one time.
*
* @return $this
*/
Expand All @@ -144,9 +166,9 @@ public function once()
}

/**
* Set the callback to only be invoked the given number of times
* Set the maximum number of callback invocations to allow.
*
* @param int $times maimum iterations of invocations to allow
* @param int $times The maximum iterations of invocations to allow
*
* @return $this
*/
Expand All @@ -158,7 +180,7 @@ public function onlyXtimes($times)
}

/**
* Prevent the callback from being triggered again
* Prevent the callback from being triggered again.
*
* @return $this
*/
Expand All @@ -170,9 +192,9 @@ public function bypass()
}

/**
* Set the priority the callback should be registered with
* Set the priority the callback should be registered with.
*
* @param string|int $priority
* @param mixed $priority The callback priority
*
* @return $this
*/
Expand All @@ -188,9 +210,9 @@ public function withPriority($priority)
}

/**
* Whether or not the callback has reached the limit of allowed invocations
* Whether or not the callback has reached the limit of allowed invocations.
*
* @return boolean true for limit reached, otherwise false
* @return boolean true for limit reached/exceeded, otherwise false
*/
protected function hasExceededIterations()
{
Expand Down
5 changes: 5 additions & 0 deletions src/Exception/WP_ErrorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

class WP_ErrorException extends \RuntimeException
{
/**
* WP_ErrorException Constructor.
*
* @param WP_Error $error The error to set the message from
*/
public function __construct(WP_Error $error)
{
$this->message = $error->get_error_message();
Expand Down
41 changes: 30 additions & 11 deletions src/Meta/Meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,33 @@ class Meta
* @var string
*/
protected $type;

/**
* The object ID this metadata is for
* @var int
*/
protected $object_id;

/**
* The key the metadata is for
* @var string
*/
protected $key;

/**
* Meta Constructor.
*
* @param string $type Meta type
* @param int|string $object_id ID of the object metadata is for
* @param string $key Meta key
*/
public function __construct($type, $object_id, $key)
{
$this->type = $type;
$this->object_id = $object_id;
$this->object_id = (int) $object_id;
$this->key = $key;
}

/**
* Get the single meta data
* Get the single meta data.
*
* @return mixed
*/
Expand All @@ -39,7 +47,7 @@ public function get()
}

/**
* Get all meta data
* Get all meta data.
*
* @return Collection
*/
Expand All @@ -49,7 +57,7 @@ public function all()
}

/**
* Set the meta value
* Set the meta value.
*
* @param mixed $value
* @param string $prev_value
Expand All @@ -62,10 +70,12 @@ public function set($value, $prev_value = '')
}

/**
* Add metadata for the specified object
* Add metadata for the specified object.
*
* @param mixed $value The value to add
* @param bool $unique
* @param bool $unique Whether the specified metadata key should be unique
* for the object. If true, and the object already has
* a value for the specified metadata key, no change will be made.
*
* @return int|false The meta ID on success, false on failure.
*/
Expand Down Expand Up @@ -93,7 +103,7 @@ public function delete($value = '')
}

/**
* Determine if a meta key is set for a given object
* Determine if a meta key is set for a given object.
*
* @return bool True of the key is set, false if not.
*/
Expand All @@ -103,23 +113,32 @@ public function exists()
}

/**
* Get the object_id
* Get the object_id.
*
* @return int|string
* @return int Object ID
*/
public function getObjectId()
{
return $this->object_id;
}

/**
* Magic getter.
*
* @param string $property The called unaccessible property name
*
* @return mixed
*/
public function __get($property)
{
return $this->get($property);
}

/**
* Get the string representation of the meta data.
*
* @return string The meta value
*/
public function __toString()
{
return $this->get();
Expand Down
14 changes: 14 additions & 0 deletions src/Post/Exception/ModelPostTypeMismatchException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,23 @@ class ModelPostTypeMismatchException extends \RuntimeException
{
const MESSAGE_FORMAT = '{modelClass} instantiated with post of type "{givenPostType}", but requires a post of type "{modelPostType}".';

/**
* The model's full class name
* @var string
*/
protected $modelClass;
/**
* The post object
* @var WP_Post
*/
protected $post;

/**
* ModelPostTypeMismatchException Constructor.
*
* @param string $modelClass The model's full class name
* @param WP_Post $post The post object
*/
public function __construct($modelClass, WP_Post $post)
{
$this->modelClass = $modelClass;
Expand Down
16 changes: 9 additions & 7 deletions src/Post/PostType.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class PostType
/**
* PostType Constructor
*
* @param object post type object
* @param stdClass $object The WordPress post type object
*/
public function __construct(stdClass $object)
{
Expand All @@ -38,10 +38,10 @@ public function __construct(stdClass $object)
*
* Loads an existing type, or returns a new builder for registering a new type.
*
* @param string $slug string - the post type slug ("name")
* @param string $slug The post type slug
*
* @return mixed static - if the post type has been registered
* PostTypeBuilder otherwise
* @return static|PostTypeBuilder If the post type has been registered, a new static instance is returned.
* Otherwise a new PostTypeBuilder is created for building a new post type to register.
*/
public static function make($slug)
{
Expand All @@ -55,7 +55,7 @@ public static function make($slug)
/**
* Create a new instance from an existing type.
*
* @param string $slug post type id (slug/name)
* @param string $slug The post type slug
*
* @return static
*/
Expand All @@ -71,6 +71,8 @@ public static function load($slug)
/**
* Checks if a post type with this slug has been registered.
*
* @param string $slug The post type slug
*
* @return bool
*/
public static function exists($slug)
Expand All @@ -91,8 +93,8 @@ public function object()
/**
* Check for feature support.
*
* @param mixed $features string - feature
* array - many features
* @param string,...|array $features string - First feature of possible many,
* array - Many features to check support for.
*
* @return mixed
*/
Expand Down
Loading

0 comments on commit a9d1137

Please sign in to comment.