ConstraintUtils::isDevConstraint()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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