Basho\Riak\Object::__construct PHP Method

__construct() public method

public __construct ( mixed | null $data = null, array | null $headers = [] )
$data mixed | null
$headers array | null DEPRECATED
    public function __construct($data = null, $headers = [])
    {
        $this->data = $data;
        if (empty($headers) || !is_array($headers)) {
            return;
        }
        $this->indexes = (new SecondaryIndex())->extractIndexesFromHeaders($headers);
        // to prevent breaking the interface, parse $headers and place important stuff in new home
        if (!empty($headers[Riak\Api\Http::CONTENT_TYPE_KEY])) {
            // if charset is defined within the Content-Type header
            if (strpos($headers[Riak\Api\Http::CONTENT_TYPE_KEY], 'charset')) {
                $parts = explode(';', trim($headers[Riak\Api\Http::CONTENT_TYPE_KEY]));
                $this->content_type = $parts[0];
                $this->charset = trim(strrpos($parts[1], '='));
            } else {
                $this->content_type = $headers[Riak\Api\Http::CONTENT_TYPE_KEY];
            }
        }
        if (!empty($headers[Riak\Api\Http::VCLOCK_KEY])) {
            $this->vclock = $headers[Riak\Api\Http::VCLOCK_KEY];
        }
        // pull out metadata headers
        foreach ($headers as $key => $value) {
            if (strpos($key, Riak\Api\Http::METADATA_PREFIX) !== false) {
                $this->metadata[substr($key, strlen(Riak\Api\Http::METADATA_PREFIX))] = $value;
            }
        }
    }