Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
Key
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getRequire
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\Define;
10
11class Key
12{
13    /** @var string|int|null key名 */
14    private $name;
15
16    /** @var bool */
17    private $require;
18
19    /**
20     * インスタンスを生成します
21     *
22     * @param string|int|null $name key名を指定します。index arrayの場合はnullを渡します。
23     *
24     * @return Key
25     */
26    public function __construct(string|int|null $name, bool $require)
27    {
28        $this->name    = $name;
29        $this->require = $require;
30    }
31
32    /**
33     * key名を取得します
34     *
35     * @return string|int|null key名を返します
36     */
37    public function getName()
38    {
39        return $this->name;
40    }
41
42    /**
43     * keyの必須有無を取得します
44     *
45     * @return bool 必須の場合はtrueを、それ以外の場合はfalseを返します
46     */
47    public function getRequire()
48    {
49        return $this->require;
50    }
51}