StringifyCallbackTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 16
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getCallbackAsString() 0 7 3
1
<?php
2
/**
3
 * Particle.
4
 *
5
 * @link      http://github.com/particle-php for the canonical source repository
6
 * @copyright Copyright (c) 2005-2016 Particle (http://particle-php.com)
7
 * @license   https://github.com/particle-php/validator/blob/master/LICENSE New BSD License
8
 */
9
namespace Particle\Validator;
10
11
/**
12
 * This Trait is for rendering callable objects to a string, if that's possible.
13
 *
14
 * @package Particle\Validator
15
 */
16
trait StringifyCallbackTrait
17
{
18
    /**
19
     * Returns a string representation of a callback, if it implements the __toString method.
20
     *
21
     * @param callable|null $callback
22
     * @return string
23
     */
24 19
    protected function getCallbackAsString($callback)
25
    {
26 19
        if (is_object($callback) && method_exists($callback, '__toString')) {
27 1
            return (string) $callback;
28
        }
29 18
        return '';
30
    }
31
}
32