Completed
Push — 2.0 ( 0357a9...3fe951 )
by Peter
08:22 queued 10s
created

SubstringExecutor   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 8 2
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * This file is part of the Happyr Doctrine Specification package.
6
 *
7
 * (c) Tobias Nyholm <[email protected]>
8
 *     Kacper Gunia <[email protected]>
9
 *     Peter Gribanov <[email protected]>
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 */
14
15
namespace Happyr\DoctrineSpecification\Operand\PlatformFunction\Executor;
16
17
final class SubstringExecutor
18
{
19
    /**
20
     * @param string   $string
21
     * @param int      $offset
22
     * @param int|null $length
23
     *
24
     * @return false|string
25
     */
26
    public function __invoke(string $string, int $offset, ?int $length = null)
27
    {
28
        if (null === $length) {
29
            return substr($string, $offset);
30
        }
31
32
        return substr($string, $offset, $length);
33
    }
34
}
35