Criteria

Replaces #1. Core idea: Class representations of criteria that a query must match. Criteria can contain state and other various information that affect how it affects the query.

```php
<?php
$repo = new MyRepository(/* ... */);
$criteria = new MyCriteria();
$criteria->setUser($user);
$criteria->setProject($project);
$repo->getForCriteria($criteria);

class MyRepository extends DatabaseRepository
{
	public function getForProject(Project $project)
	{
		$criteria = new MyCriteria();
		$criteria->setProject($project);
		$this->pushCriteria($criteria);
		return $this->getAll();
	}

	public function getForUser(User $user)
	{
		$criteria = new MyCriteria();
		$criteria->setUser($user);
		$this->pushCriteria($criteria);
		return $this->getAll();
	}

	public function getForProjectUser(Project $project, User $user)
	{
		$criteria = new MyCriteria();
		$criteria->setUser($user);
		$criteria->setProject($project);
		$this->pushCriteria($criteria);
		return $this->getAll();
	}
}

class MyCriteria implements CriteriaInterface
{
	protected $project;
	protected $user;

	public function setProject(Project $project)
	{
		$this->project = $project;
	}

	public function setUser(User $user)
	{
		$this->user = $user;
	}

	public function apply($query)
	{
		if ($this->project) {
			// lots of intricate joins here maybe?
			$query->where('project_id', '=', $this->project->getKey());
		}

		if ($this->user) {
			// lots of intricate joins here maybe?
			$query->where('user_id', '=', $this->user->getKey());
		}
	}
}
```