Completed
Pull Request — master (#1)
by Guillaume
07:09
created

HtmlValidator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 14
rs 10
c 1
b 0
f 0
wmc 2
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A check() 0 8 2
1
<?php
2
3
/*
4
 * This file is part of the hogosha-monitor package
5
 *
6
 * Copyright (c) 2016 Guillaume Cavana
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * Feel free to edit as you please, and have fun.
12
 *
13
 * @author Guillaume Cavana <[email protected]>
14
 */
15
16
namespace Hogosha\Monitor\Validator;
17
18
use Hogosha\Monitor\Exception\ValidatorException;
19
20
/**
21
 * Class HtmlValidator.
22
 */
23
class HtmlValidator implements ValidatorInterface
24
{
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function check($value, $match)
29
    {
30
        preg_match(sprintf('%s', $match), $value, $matches);
31
32
        if (false == isset($matches[0])) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
33
            throw new ValidatorException(sprintf('this string "%s" cannot be found', $match));
34
        }
35
    }
36
}
37