Reformatted and checked everything. [skip ci]

This commit is contained in:
James Cole
2014-07-25 13:02:01 +02:00
parent bcd48f2e49
commit 30d5b88769
45 changed files with 980 additions and 330 deletions

View File

@@ -3,14 +3,29 @@
namespace Firefly\Storage\Component;
/**
* Interface ComponentRepositoryInterface
*
* @package Firefly\Storage\Component
*/
interface ComponentRepositoryInterface
{
/**
* @return mixed
*/
public function count();
/**
* @return mixed
*/
public function get();
/**
* @param $data
*
* @return mixed
*/
public function store($data);
}

View File

@@ -3,32 +3,56 @@
namespace Firefly\Storage\Component;
use Firefly\Exception\FireflyException;
use Illuminate\Database\QueryException;
/**
* Class EloquentComponentRepository
*
* @package Firefly\Storage\Component
*/
class EloquentComponentRepository implements ComponentRepositoryInterface
{
public $validator;
/**
*
*/
public function __construct()
{
}
/**
* @return mixed
*/
public function count()
{
return \Auth::user()->components()->count();
}
/**
* @return mixed|void
* @throws \Firefly\Exception\FireflyException
*/
public function get()
{
die('no impl');
throw new FireflyException('No implementation.');
}
/**
* @param $data
*
* @return \Budget|\Category|mixed
* @throws \Firefly\Exception\FireflyException
*/
public function store($data)
{
if (!isset($data['class'])) {
throw new \Firefly\Exception\FireflyException('No class type present.');
throw new FireflyException('No class type present.');
}
switch ($data['class']) {
default:
case 'Budget':
$component = new \Budget;
break;
@@ -41,9 +65,9 @@ class EloquentComponentRepository implements ComponentRepositoryInterface
$component->user()->associate(\Auth::user());
try {
$component->save();
} catch (\Illuminate\Database\QueryException $e) {
} catch (QueryException $e) {
\Log::error('DB ERROR: ' . $e->getMessage());
throw new \Firefly\Exception\FireflyException('Could not save component ' . $data['name'] . ' of type'
throw new FireflyException('Could not save component ' . $data['name'] . ' of type'
. $data['class']);
}