ValidateMessageImplementation   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 0
dl 0
loc 34
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A validate() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Copyright (C) 2016 Billie Thompson
7
 *
8
 * This software may be modified and distributed under the terms
9
 * of the MIT license.  See the LICENSE file for details.
10
 */
11
12
namespace PurpleBooth\GitLintValidators;
13
14
use PurpleBooth\GitLintValidators\Validator\Validator;
15
16
/**
17
 * Validate against a number of validators against a message.
18
 */
19
class ValidateMessageImplementation implements ValidateMessage
20
{
21
    /**
22
     * @var array
23
     */
24
    private $validators;
25
26
    /**
27
     * ValidationServiceImplementation constructor.
28
     *
29
     * @param array $validators
30
     */
31
    public function __construct(array $validators)
32
    {
33
        $this->validators = $validators;
34
35
        if (count($validators) < 1) {
36
            new \LogicException('You need to provide the validation service with at least 1 validator');
37
        }
38
    }
39
40
    /**
41
     * Test a message against a number of validators.
42
     *
43
     * @param Message $message
44
     */
45
    public function validate(Message $message)
46
    {
47
        /** @var Validator $validator */
48
        foreach ($this->validators as $validator) {
49
            $validator->validate($message);
50
        }
51
    }
52
}
53