for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Created by Maciej Paprocki for Bureau-VA.
* Date: 17/02/2016
* Project Name: MaciekPaprocki\WordpressGuzzle
* Time: 10:46.
*/
namespace BureauVa\WordpressGuzzle\Query;
use BureauVa\WordpressGuzzle\Helper\StringHelper as S;
* Class AbstractRepository.
abstract class RepositoryAbstract
{
public static $BASE_PATH = 'posts';
* @return string
public function __toString()
$ar = (array) $this;
return $this->prepareCall($ar);
}
* @param $ar
*
private function prepareCall($ar)
if (count($ar) === 1 && isset($ar['post__in']) && is_numeric($ar['post__in'])) {
return self::$BASE_PATH.'/'.$ar['post__in'];
return self::$BASE_PATH.'?'.http_build_query([
'filter' => $ar,
]);
* @param $method
* @param $params
* @return $this
public function __call($method, $params)
if (substr($method, 0, 5) == 'where') {
$varName = S::camelCaseToSnakeCase(mb_substr($method, 5));
$this->$varName = $params[0];
return $this;
* @param $id
public function whereId($id)
$this->post__in = (int) $id;
post__in
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
* Set's.
* @param $key
* @param $value
public function setNotFiltered($key, $value)
$this->$key = $value;
public function whereIds($ids)
$this->post__in = (array) $ids;
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: