Passed
Pull Request — master (#300)
by Arnaud
14:15 queued 08:05
created

RedirectionUtils::isRedirectionRequired()   A

Complexity

Conditions 5
Paths 4

Size

Total Lines 14
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 6
c 1
b 0
f 0
nc 4
nop 1
dl 0
loc 14
rs 9.6111
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LAG\AdminBundle\Routing\Redirection;
6
7
use LAG\AdminBundle\Admin\AdminInterface;
8
9
class RedirectionUtils
10
{
11
    public static function isRedirectionRequired(AdminInterface $admin): bool
12
    {
13
        // Redirection are required when a form is submitted and valid
14
        foreach ($admin->getForms() as $formName => $form) {
15
            if ($formName === 'filter') {
16
                continue;
17
            }
18
19
            if ($form->isSubmitted() && $form->isValid()) {
20
                return true;
21
            }
22
        }
23
24
        return false;
25
    }
26
}
27