ConstraintValidator   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 10
c 1
b 0
f 0
dl 0
loc 25
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isConstraint() 0 13 3
A __construct() 0 3 1
1
<?php
2
/**
3
 * Copyright © Vaimo Group. All rights reserved.
4
 * See LICENSE_VAIMO.txt for license details.
5
 */
6
namespace Vaimo\ComposerChangelogs\Validators;
7
8
class ConstraintValidator
9
{
10
    /**
11
     * @var \Composer\Semver\VersionParser
12
     */
13
    private $versionParser;
14
15
    public function __construct()
16
    {
17
        $this->versionParser = new \Composer\Semver\VersionParser();
18
    }
19
20
    public function isConstraint($value)
21
    {
22
        if (is_array($value)) {
23
            return false;
24
        }
25
26
        try {
27
            $this->versionParser->parseConstraints($value);
28
        } catch (\UnexpectedValueException $exception) {
29
            return false;
30
        }
31
32
        return true;
33
    }
34
}
35