Completed
Pull Request — master (#23)
by Vitaliy
03:07
created

ExampleMessageForm::isValid()   B

Complexity

Conditions 5
Paths 3

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
rs 8.8571
cc 5
eloc 10
nc 3
nop 0
1
<?php
2
3
  namespace Tests\Fiv\Form\Fixtures;
4
5
  use Fiv\Form\Form;
6
7
  /**
8
   *
9
   */
10
  class ExampleMessageForm extends Form {
11
12
    /**
13
     * @return bool
14
     */
15
    public function isValid() {
16
      if (!parent::isValid()) {
17
        return false;
18
      }
19
20
      if (
21
        $this->getElements()['emailFrom']->getValue() == '[email protected]'
22
        and $this->getElements()['emailTo']->getValue() == '[email protected]'
23
        and $this->getElements()['message']->getValue() == 'copy message text'
24
      ) {
25
        $this->validationResult = false;
26
        $this->addError('message duplicate error');
27
      }
28
29
      return $this->validationResult;
30
    }
31
32
  }