aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/php/lib
diff options
context:
space:
mode:
authorGravatar Jeff Ching <chingor@google.com>2018-05-16 16:45:20 -0700
committerGravatar Jeff Ching <chingor@google.com>2018-05-16 16:45:20 -0700
commit31676f36b1c58543697a9ea5e2a84961601b8156 (patch)
treea3032e0fbf94a6341d899990148e15d55a43aee2 /src/php/lib
parentb29a417643d34d0b0498059e66eb908e4cf01551 (diff)
Surface a static method to fetch the default Channel that a BaseStub would create
Diffstat (limited to 'src/php/lib')
-rw-r--r--src/php/lib/Grpc/BaseStub.php14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/php/lib/Grpc/BaseStub.php b/src/php/lib/Grpc/BaseStub.php
index 0966193107..489d96c8aa 100644
--- a/src/php/lib/Grpc/BaseStub.php
+++ b/src/php/lib/Grpc/BaseStub.php
@@ -69,6 +69,18 @@ class BaseStub
return;
}
+ $this->channel = static::getDefaultChannel($opts);
+ }
+
+ /**
+ * Creates and returns the default Channel
+ *
+ * @param array $opts Channel constructor options
+ *
+ * @return Channel The channel
+ */
+ public static function getDefaultChannel(array $opts)
+ {
$package_config = json_decode(
file_get_contents(dirname(__FILE__).'/../../composer.json'),
true
@@ -85,7 +97,7 @@ class BaseStub
'required. Please see one of the '.
'ChannelCredentials::create methods');
}
- $this->channel = new Channel($hostname, $opts);
+ return new Channel($hostname, $opts);
}
/**