* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ namespace libs\ApaiIO\Configuration; use libs\ApaiIO\Configuration\Country; /** * A generic configurationclass * * @author Jan Eichhorn */ class GenericConfiguration implements ConfigurationInterface { /** * The country * * @var string */ protected $country; /** * The accesskey * * @var string */ protected $accessKey; /** * The string * * @var string */ protected $secretKey; /** * The associate Tag * * @var string */ protected $associateTag; /** * The requestclass * By default its set to the provided restful request * * @var string */ protected $request = "\\libs\\ApaiIO\\Request\\Rest\\Request"; /** * A callback which is called before returning the request by the factory * * @var \Closure|array|string */ protected $requestFactory = null; /** * The responsetransformerclass * By default its set to null which means that no transformer will be applied * * @var string */ protected $responseTransformer = null; /** * A callback which is called before returning the responsetransformer by the factory * * @var \Closure|array|string */ protected $responseTransformerFactory = null; /** * {@inheritdoc} */ public function getCountry() { return $this->country; } /** * Sets an validates the country * * @param string $country * * @return \libs\ApaiIO\Configuration\GenericConfiguration */ public function setCountry($country) { Country::isValidCountry($country); $this->country = strtolower($country); return $this; } /** * {@inheritdoc} */ public function getAccessKey() { return $this->accessKey; } /** * Sets the accesskey * * @param string $accessKey * * @return \libs\ApaiIO\Configuration\GenericConfiguration */ public function setAccessKey($accessKey) { $this->accessKey = $accessKey; return $this; } /** * {@inheritdoc} */ public function getSecretKey() { return $this->secretKey; } /** * Sets the secretkey * * @param string $secretKey * * @return \libs\ApaiIO\Configuration\GenericConfiguration */ public function setSecretKey($secretKey) { $this->secretKey = $secretKey; return $this; } /** * {@inheritdoc} */ public function getAssociateTag() { return $this->associateTag; } /** * Sets the associatetag * * @param string $associateTag * * @return \libs\ApaiIO\Configuration\GenericConfiguration */ public function setAssociateTag($associateTag) { $this->associateTag = $associateTag; return $this; } /** * {@inheritdoc} */ public function getRequest() { return $this->request; } /** * Sets the requestclass * * @param string $request * * @return \libs\ApaiIO\Configuration\GenericConfiguration */ public function setRequest($request) { $this->request = $request; return $this; } /** * {@inheritdoc} */ public function getResponseTransformer() { return $this->responseTransformer; } /** * Sets the responsetransformerclass * * @param string $responseTransformer * * @return \libs\ApaiIO\Configuration\GenericConfiguration */ public function setResponseTransformer($responseTransformer) { $this->responseTransformer = $responseTransformer; return $this; } /** * {@inheritdoc} */ public function getRequestFactory() { return $this->requestFactory; } /** * Sets the request factory callback * * @param \Closure|array|string $callback * * @return \libs\ApaiIO\Configuration\GenericConfiguration */ public function setRequestFactory($callback) { if (!is_callable($callback)) { throw new \InvalidArgumentException("Given argument is not callable"); } $this->requestFactory = $callback; return $this; } /** * {@inheritdoc} */ public function getResponseTransformerFactory() { return $this->responseTransformerFactory; } /** * Sets the responsetransformer factory callback * * @param \Closure|array|string $callback * * @return \libs\ApaiIO\Configuration\GenericConfiguration */ public function setResponseTransformerFactory($callback) { if (!is_callable($callback)) { throw new \InvalidArgumentException("Given argument is not callable"); } $this->responseTransformerFactory = $callback; return $this; } }