for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* The MIT License (MIT)
*
* Copyright (c) 2014-2015 Spomky-Labs
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
namespace Jose\Object;
/**
* Class JWK.
final class JWK implements JWKInterface
{
* @var array
protected $values = [];
* JWK constructor.
* @param array $values
public function __construct(array $values = [])
$this->values = $values;
}
* {@inheritdoc}
public function jsonSerialize()
return $this->getAll();
public function get($key)
if ($this->has($key)) {
return $this->values[$key];
throw new \InvalidArgumentException(sprintf('The value identified by "%s" does not exist.', $key));
public function has($key)
return array_key_exists($key, $this->getAll());
public function getKeys()
return array_keys($this->values);
public function getAll()
return $this->values;
public function withValue($key, $value)
$jwk = clone $this;
$jwk->values[$key] = $value;
return $jwk;
public function withoutValue($key)
if (!array_key_exists($key, $this->values)) {
return $this;
unset($jwk->values[$key]);