This repository has been archived by the owner on May 25, 2021. It is now read-only.
forked from census-instrumentation/opencensus-php
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from nenadstojanovikj/minor/update-propagator-…
…interface Update PropagatorInterface
- Loading branch information
Showing
16 changed files
with
193 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace OpenCensus\Trace\Propagator; | ||
|
||
class ArrayHeaders implements HeaderSetter, HeaderGetter, \IteratorAggregate, \ArrayAccess | ||
{ | ||
/** | ||
* @var string[] | ||
*/ | ||
private $headers; | ||
|
||
/** | ||
* @param string[] $headers An associative array with header name as key | ||
*/ | ||
public function __construct(array $headers = []) | ||
{ | ||
$this->headers = $headers; | ||
} | ||
|
||
public function get(string $header): ?string | ||
{ | ||
return $this->headers[$header] ?? null; | ||
} | ||
|
||
public function set(string $header, string $value): void | ||
{ | ||
$this->headers[$header] = $value; | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return $this->headers; | ||
} | ||
|
||
public function getIterator() | ||
{ | ||
return new \ArrayIterator($this->headers); | ||
} | ||
|
||
public function offsetExists($offset) | ||
{ | ||
return isset($this->headers[$offset]); | ||
} | ||
|
||
public function offsetGet($offset) | ||
{ | ||
return $this->get($offset); | ||
} | ||
|
||
public function offsetSet($offset, $value) | ||
{ | ||
$this->set($offset, $value); | ||
} | ||
|
||
public function offsetUnset($offset) | ||
{ | ||
unset($this->headers[$offset]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace OpenCensus\Trace\Propagator; | ||
|
||
interface HeaderGetter | ||
{ | ||
/** | ||
* @param string $header Header name | ||
* @return string|null | ||
*/ | ||
public function get(string $header): ?string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace OpenCensus\Trace\Propagator; | ||
|
||
interface HeaderSetter | ||
{ | ||
/** | ||
* @param string $header Header name | ||
* @param string $value Header value | ||
*/ | ||
public function set(string $header, string $value): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.