Skip to content

Commit

Permalink
Add optional datbase URI parameter to the factory
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegamez committed Aug 16, 2016
1 parent b924ded commit 08352c5
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/Firebase.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,41 @@
<?php

use Firebase\Exception\InvalidArgumentException;
use Firebase\ServiceAccount;
use Firebase\V2;
use Firebase\V3;
use Psr\Http\Message\UriInterface;

/**
* Convenience class to comfortably create new Firebase instances.
*/
final class Firebase
{
public static function fromServiceAccount($serviceAccount): V3\Firebase
/**
* Creates a new Firebase V3 instance.
*
* @param string|ServiceAccount $serviceAccount Path to service account JSON config or a ServiceAccount instance
* @param string|UriInterface|null $databaseUri Database URI
*
* @throws InvalidArgumentException
*
* @return V3\Firebase
*/
public static function fromServiceAccount($serviceAccount, $databaseUri = null): V3\Firebase
{
return V3\Firebase::fromServiceAccount($serviceAccount);
return V3\Firebase::fromServiceAccount($serviceAccount, $databaseUri);
}

/**
* Creates a new Firebase V2 instance.
*
* @param string|UriInterface $databaseUri Database URI as a string or an instance of UriInterface
* @param string $secret
*
* @throws InvalidArgumentException
*
* @return V2\Firebase
*/
public static function fromDatabaseUriAndSecret($databaseUri, string $secret): V2\Firebase
{
return V2\Firebase::fromDatabaseUriAndSecret($databaseUri, $secret);
Expand Down

0 comments on commit 08352c5

Please sign in to comment.