GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ObjectMockForSprintf   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 7
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 4 1
1
<?php
2
/*
3
 * This file is part of StringTemplate.
4
 *
5
 * (c) 2013 Nicolò Martini
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace StringTemplate\Test;
11
12
use StringTemplate\SprintfEngine;
13
14
/**
15
 * Unit tests for class Engine
16
 */
17
class SprintfEngineTest extends \PHPUnit_Framework_TestCase
18
{
19
20
    public function testRender()
21
    {
22
        $engine = new SprintfEngine();
23
        $this->assertEquals(
24
            sprintf('Oh! %s %s jumped onto %s (%e) table', 'The', 'cat', 1, 1),
25
            $engine->render(
26
                'Oh! {subj.det%s} {subj.np%s} {verb} onto {w.where.number%s} ({w.where.number%e}) {w.where.np}',
27
                array(
28
                    'verb' => 'jumped',
29
                    'subj' => array('det' => 'The', 'np' => 'cat'),
30
                    'w' => array('where' => array('number' => 1, 'np' => 'table'))
31
                )
32
            )
33
        );
34
    }
35
36
    public function testRenderWithObjectValues()
37
    {
38
        $engine = new SprintfEngine();
39
        $this->assertEquals(
40
            'foo',
41
            $engine->render(
42
                '{val%s}',
43
                array('val' => new ObjectMockForSprintf())
44
            )
45
        );
46
    }
47
48
    public function testRenderWithAdditionalFormatting()
49
    {
50
        $engine = new SprintfEngine();
51
        $this->assertEquals(
52
            'I have 1.2 (1.230000E+0) apples.',
53
            $engine->render(
54
                "I have {num%.1f} ({num%.6E}) {fruit}.",
55
                array(
56
                    'num' => 1.23,
57
                    'fruit' => 'apples'
58
                )
59
            )
60
        );
61
    }
62
}
63
64
class ObjectMockForSprintf
65
{
66
    function __toString()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
67
    {
68
        return 'foo';
69
    }
70
}