UserRepository::delete()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
namespace Core\Models\User;
3
4
use Propel\Runtime\ActiveRecord\ActiveRecordInterface;
5
use Frameworkless\Exceptions\ValidationException;
6
7
/**
8
 * Description of UserRepo
9
 *
10
 * @author Dmitriy
11
 */
12
class UserRepository implements \Frameworkless\CrudInterface{
13
14
    public function find(array $conditions = []){
15
	return UserQuery::create()->findOneByArray($conditions);
16
    }
17
18
    /**
19
     * Поиск по id
20
     * @param type $id
21
     * @return \Models\User\User $User
22
     * @throws \InvalidArgumentException
23
     */
24
    public function findById($id){
25
	if(!$User = UserQuery::create()->findPk($id)){
26
	    throw new \InvalidArgumentException(sprintf('User with ID %d does not exist', $id));
27
	}
28
29
	return $User;
30
    }
31
32
    public function findMany(array $conditions = [], $limit = false){
33
	$Users = UserQuery::create()
34
		->_if($limit)
35
		->limit($limit)
36
		->_endif()
37
		->findByArray($conditions);
38
	return $Users;
39
    }
40
41
    public function delete(ActiveRecordInterface $Model){
42
	return $Model->delete();
43
    }
44
45
    /**
46
     * Сохраняем
47
     * @param ActiveRecordInterface $Model
48
     * @return boolean
49
     * @throws \DomainException
50
     */
51
    public function save(ActiveRecordInterface $Model){
52
	return $Model->save();
53
    }
54
55
    /**
56
     * 
57
     * @return \Core\Models\User\User $User
58
     */
59
    public function build(){
60
	return new User;
61
    }
62
}
63