Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
7 / 7
CRAP
100.00% covered (success)
100.00%
1 / 1
ValidateResult
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
7 / 7
7
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 setResult
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 setArrayPath
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 setMessage
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getResult
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getArrayPath
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getMessage
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * @license MIT
5 * @author hazuki3417<hazuki3417@gmail.com>
6 * @copyright 2022 hazuki3417 all rights reserved.
7 */
8
9namespace Selen\Schema\Validate\Model;
10
11class ValidateResult
12{
13    /** @var bool */
14    private $result = true;
15
16    /** @var string */
17    private $arrayPath = '';
18
19    /** @var string */
20    private $message = '';
21
22    /**
23     * インスタンスを生成します
24     *
25     * @param bool   $result  検証結果を渡します。成功の場合はtrueを、失敗の場合はfalseを設定します
26     * @param string $message 配列の階層パスを渡します
27     * @param string $message メッセージを渡します
28     */
29    public function __construct(bool $result = true, string $arrayPath = '', string $message = '')
30    {
31        $this->result    = $result;
32        $this->arrayPath = $arrayPath;
33        $this->message   = $message;
34    }
35
36    /**
37     * 検証結果を設定します
38     *
39     * @param bool $value 検証結果を渡します
40     */
41    public function setResult(bool $value): ValidateResult
42    {
43        $this->result = $value;
44        return $this;
45    }
46
47    public function setArrayPath(string $value): ValidateResult
48    {
49        $this->arrayPath = $value;
50        return $this;
51    }
52
53    /**
54     * メッセージを設定します
55     *
56     * @param string $value メッセージ文字列を渡します
57     */
58    public function setMessage(string $value): ValidateResult
59    {
60        $this->message = $value;
61        return $this;
62    }
63
64    /**
65     * 検証結果を取得します
66     *
67     * @return bool 成功の場合はtrueを、失敗の場合はfalseを返します
68     */
69    public function getResult(): bool
70    {
71        return $this->result;
72    }
73
74    /**
75     * 配列の階層パスを取得します
76     *
77     * @return string 配列の階層パスを返します
78     */
79    public function getArrayPath(): string
80    {
81        return $this->arrayPath;
82    }
83
84    /**
85     * メッセージを取得します
86     *
87     * @return string メッセージを返します
88     */
89    public function getMessage(): string
90    {
91        return $this->message;
92    }
93}