Skip to content

Commit

Permalink
PSR2 tidyup
Browse files Browse the repository at this point in the history
  • Loading branch information
ciaranmaher committed Sep 1, 2014
1 parent 672e9ea commit eda5e19
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 26 deletions.
7 changes: 4 additions & 3 deletions src/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@ class Category extends Term
{
/**
* Override the default query to do all the category joins
*
*
* @param boolean $excludeDeleted Include soft deleted columns
*
*
* @return object The query object
*/
public function newQuery($excludeDeleted = true)
{
$query = parent::newQuery($excludeDeleted);
$query->where('taxonomy', '=', 'category');

return $query;
}

/**
* Return parent category
*
* @return
* @return
*/
public function parents()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Comment extends Eloquent

/**
* Define user meta relationship
*
*
* @return object
*/
public function meta()
Expand Down
4 changes: 2 additions & 2 deletions src/CommentMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class CommentMeta extends Eloquent

/**
* Override the default Collection
*
*
* @param array $models
*
* @return \Square1\Wordpressed\UserMetaCollection
Expand All @@ -34,7 +34,7 @@ public function newCollection(array $models = [])

/**
* Define user relationship
*
*
* @return object
*/
public function comment()
Expand Down
5 changes: 3 additions & 2 deletions src/Format.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ class Format extends Term
{
/**
* Override the default query to do all the post format joins
*
*
* @param boolean $excludeDeleted Include soft deleted columns
*
*
* @return object The query object
*/
public function newQuery($excludeDeleted = true)
{
$query = parent::newQuery($excludeDeleted);
$query->where('taxonomy', '=', 'post_format');

return $query;
}
}
6 changes: 3 additions & 3 deletions src/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ class Manager

/**
* Connect to the Wordpress database
*
*
* @param array $config
*/
public function __construct(array $config = [])
{
$this->capsule = new Capsule;
$this->capsule = new Capsule();
$this->capsule->addConnection(array_merge($this->config, $config));
$this->capsule->bootEloquent();
}

/**
* Get the query log
*
*
* @return array
*/
public function getQueryLog()
Expand Down
2 changes: 1 addition & 1 deletion src/MetaCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class MetaCollection extends Collection
{
/**
* Return value for the given key
*
*
* @param string $key
*
* @return string
Expand Down
3 changes: 2 additions & 1 deletion src/MetaTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ trait MetaTrait
{
/**
* Return meta value from parent object via a magic method
*
*
* @param string $key
*
* @return string
Expand All @@ -14,6 +14,7 @@ public function __get($key)
if (!isset($this->$key)) {
return $this->meta->$key;
}

return parent::__get($key);
}
}
10 changes: 7 additions & 3 deletions src/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public function newQuery($excludeDeleted = true)
$query = parent::newQuery($excludeDeleted);

$query->where('post_type', $this->postType);

return $query;
}

Expand Down Expand Up @@ -162,6 +163,7 @@ public function scopeSlug($query, $slug)
if (!is_array($slug)) {
return $query->where('post_name', $slug);
}

return $query->whereIn('post_name', $slug);
}

Expand All @@ -178,6 +180,7 @@ public function scopeId($query, $id)
if (!is_array($id)) {
return $query->where('ID', $id);
}

return $query->whereIn('ID', $id);
}

Expand Down Expand Up @@ -224,8 +227,8 @@ public function scopeFormat($query, $slug)
* Get posts with a given taxonomy
*
* @param object $query The query object
* @param string $name The taxonomy name
* @param string $slug The slug name
* @param string $name The taxonomy name
* @param string $slug The slug name
*
* @return object The query object
*/
Expand Down Expand Up @@ -259,6 +262,7 @@ protected function taxonomy($query, $name, $slug)
if (!is_array($slug)) {
return $query->where("terms{$postfix}.slug", $slug);
}

return $query->whereIn("terms{$postfix}.slug", $slug);
}

Expand All @@ -278,7 +282,7 @@ public function scopeStatus($query, $status = '')
/**
* Get posts with a given post type
*
* @param string $type
* @param string $type
* @return \Corcel\PostBuilder
*/
public function scopeType($query, $type)
Expand Down
4 changes: 2 additions & 2 deletions src/PostMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class PostMeta extends Eloquent

/**
* Override the default Collection
*
*
* @param array $models
*
* @return \Square1\Wordpressed\MetaCollection
Expand All @@ -34,7 +34,7 @@ public function newCollection(array $models = [])

/**
* Define post relationship
*
*
* @return object
*/
public function post()
Expand Down
5 changes: 3 additions & 2 deletions src/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ class Tag extends Term
{
/**
* Override the default query to do all the tag joins
*
*
* @param boolean $excludeDeleted Include soft deleted columns
*
*
* @return object The query object
*/
public function newQuery($excludeDeleted = true)
{
$query = parent::newQuery($excludeDeleted);
$query->where('taxonomy', '=', 'post_tag');

return $query;
}
}
8 changes: 5 additions & 3 deletions src/Term.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ class Term extends Eloquent

/**
* Override the default query to do all the category joins
*
*
* @param boolean $excludeDeleted Include soft deleted columns
*
*
* @return object The query object
*/
public function newQuery($excludeDeleted = true)
{
$query = parent::newQuery($excludeDeleted);
$query->join('terms', 'term_taxonomy.term_id', '=', 'terms.term_id');

return $query;
}

Expand All @@ -38,14 +39,15 @@ public function newQuery($excludeDeleted = true)
*
* @param object $query The query object
* @param array|string $slug The name(s) of the slug(s)
*
*
* @return object The query object
*/
public function scopeSlug($query, $slug)
{
if (!is_array($slug)) {
return $query->where('slug', $slug);
}

return $query->whereIn('slug', $slug);
}
}
3 changes: 2 additions & 1 deletion src/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class User extends Eloquent

/**
* Define user meta relationship
*
*
* @return object
*/
public function meta()
Expand Down Expand Up @@ -62,6 +62,7 @@ public function scopeName($query, $name)
if (!is_array($name)) {
return $query->where('user_nicename', $name);
}

return $query->whereIn('user_nicename', $name);
}
}
4 changes: 2 additions & 2 deletions src/UserMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class UserMeta extends Eloquent

/**
* Override the default Collection
*
*
* @param array $models
*
* @return \Square1\Wordpressed\UserMetaCollection
Expand All @@ -34,7 +34,7 @@ public function newCollection(array $models = [])

/**
* Define user relationship
*
*
* @return object
*/
public function user()
Expand Down

0 comments on commit eda5e19

Please sign in to comment.