Skip to content

Commit

Permalink
Merge pull request #19 from danalloway/master
Browse files Browse the repository at this point in the history
use late-static binding to new up client
  • Loading branch information
marcqualie committed May 17, 2015
2 parents b867ba7 + 43e8fb0 commit dbeb292
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Client
public static function instance($name = 'default')
{
if (! isset(self::$instances[$name])) {
self::$instances[$name] = new Client($name);
self::$instances[$name] = new static($name);
}
return self::$instances[$name];
}
Expand Down
8 changes: 8 additions & 0 deletions tests/LateStaticClient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace League\StatsD\Test;

class LateStaticClient extends \League\StatsD\Client
{

}
15 changes: 15 additions & 0 deletions tests/LateStaticClientTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace League\StatsD\Test;

class LateStaticClientTest extends TestCase
{

public function testStaticInstance()
{
$client = new LateStaticClient();
$instance = LateStaticClient::instance();
$this->assertTrue($instance instanceof LateStaticClient);
}

}

0 comments on commit dbeb292

Please sign in to comment.