VersionResolver   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A resolveValidVersion() 0 9 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\Resolvers;
7
8
class VersionResolver
9
{
10
    /**
11
     * @var \Vaimo\ComposerChangelogs\Validators\ConstraintValidator
12
     */
13
    private $constraintValidator;
14
    
15
    public function __construct()
16
    {
17
        $this->constraintValidator = new \Vaimo\ComposerChangelogs\Validators\ConstraintValidator();
18
    }
19
    
20
    public function resolveValidVersion($value)
21
    {
22
        $segments = explode('.', $value);
23
        
24
        while (!empty($segments) && !$this->constraintValidator->isConstraint(implode('.', $segments))) {
25
            array_shift($segments);
26
        }
27
28
        return implode('.', $segments);
29
    }
30
}
31