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\MongoDB\Validator\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    /**
48     * 配列の階層パスを設定します
49     *
50     * @param string $value 配列の階層パスを渡します
51     */
52    public function setArrayPath(string $value): ValidateResult
53    {
54        $this->arrayPath = $value;
55        return $this;
56    }
57
58    /**
59     * メッセージを設定します
60     *
61     * @param string $value メッセージ文字列を渡します
62     */
63    public function setMessage(string $value): ValidateResult
64    {
65        $this->message = $value;
66        return $this;
67    }
68
69    /**
70     * 検証結果を取得します
71     *
72     * @return bool 成功の場合はtrueを、失敗の場合はfalseを返します
73     */
74    public function getResult(): bool
75    {
76        return $this->result;
77    }
78
79    /**
80     * 配列の階層パスを取得します
81     *
82     * @return string 配列の階層パスを返します
83     */
84    public function getArrayPath(): string
85    {
86        return $this->arrayPath;
87    }
88
89    /**
90     * メッセージを取得します
91     *
92     * @return string メッセージを返します
93     */
94    public function getMessage(): string
95    {
96        return $this->message;
97    }
98}