Passed
Branch feature/6.x (3df42d)
by Schlaefer
08:49
created

ContactForm   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 26
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A _buildSchema() 0 6 1
A validationDefault() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * Saito - The Threaded Web Forum
7
 *
8
 * @copyright Copyright (c) the Saito Project Developers
9
 * @link https://github.com/Schlaefer/Saito
10
 * @license http://opensource.org/licenses/MIT
11
 */
12
13
namespace App\Form;
14
15
use Cake\Form\Form;
16
use Cake\Form\Schema;
17
use Cake\Validation\Validator;
18
19
class ContactForm extends Form
20
{
21
22
    /**
23
     * {@inheritdoc}
24
     *
25
     * @param \Cake\Form\Schema $schema The schema to customize.
26
     * @return \Cake\Form\Schema The schema to use.
27
     */
28
    protected function _buildSchema(Schema $schema): Schema
29
    {
30
        return $schema
31
            ->addField('subject', 'string')
32
            ->addField('text', ['type' => 'text'])
33
            ->addField('cc', ['type' => 'boolean']);
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     *
39
     * @param \Cake\Validation\Validator $validator The validator to customize.
40
     * @return \Cake\Validation\Validator The validator to use.
41
     */
42
    public function validationDefault(Validator $validator): Validator
43
    {
44
        return $validator->notEmptyString('subject', __('error_subject_empty'));
45
    }
46
}
47