ConstraintUtils   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isConstraint() 0 13 3
A __construct() 0 3 1
A isDevConstraint() 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\ComposerPatches\Utils;
7
8
class ConstraintUtils
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
    public function isDevConstraint($value)
36
    {
37
        return strpos($value, 'dev-') === 0;
38
    }
39
}
40