ModelException::invalid()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 2
1
<?php
2
3
namespace As3\Modlr\Store;
4
5
use As3\Modlr\Exception\AbstractHttpException;
6
7
/**
8
 * Persister exceptions.
9
 *
10
 * @author Jacob Bare <[email protected]>
11
 */
12
class ModelException extends AbstractHttpException
13
{
14
    public static function cannotModifyInverse(Model $model, $fieldKey)
15
    {
16
        return new self(
17
            sprintf(
18
                'Oops! The requested action for model type "%s" is invalid. The relationship field "%s" is inversed (not owned) and cannot be modified.',
19
                $model->getType(),
20
                $fieldKey
21
            ),
22
            400,
23
            __FUNCTION__
24
        );
25
    }
26
    public static function invalid(Model $model, $message = null)
27
    {
28
        return new self(
29
            sprintf(
30
                'Oops! The requested action for model type "%s" is invalid. %s',
31
                $model->getType(),
32
                $message
33
            ),
34
            400,
35
            __FUNCTION__
36
        );
37
    }
38
}
39