Overview
  • Namespace
  • Class

Namespaces

  • Klarna
    • XMLRPC
      • Exception

Interfaces

  • Klarna\XMLRPC\Exception\KlarnaException
  1 <?php
  2 /**
  3  * Copyright 2016 Klarna AB.
  4  *
  5  * Licensed under the Apache License, Version 2.0 (the "License");
  6  * you may not use this file except in compliance with the License.
  7  * You may obtain a copy of the License at
  8  *
  9  *     http://www.apache.org/licenses/LICENSE-2.0
 10  *
 11  * Unless required by applicable law or agreed to in writing, software
 12  * distributed under the License is distributed on an "AS IS" BASIS,
 13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  * See the License for the specific language governing permissions and
 15  * limitations under the License.
 16  */
 17 namespace Klarna\XMLRPC;
 18 
 19 /**
 20  * Configuration class for the Klarna instance.
 21  *
 22  * You add settings using the ArrayAccess:<br>
 23  * $arr['field'] = $val or $arr->offsetSet('field', $val);<br>
 24  *
 25  * Available settings are:<br>
 26  * eid         - Merchant ID (int)
 27  * secret      - Shared secret (string)
 28  * country     - Country constant or code  (int|string)
 29  * language    - Language constant or code (int|string)
 30  * currency    - Currency constant or code (int|string)
 31  * mode        - Klarna::BETA or Klarna::LIVE
 32  * xmlrpcDebug - XMLRPC debugging (bool)
 33  * debug       - Normal debugging (bool)
 34  * timeout     - XMLRPC timeout in seconds (int)
 35  */
 36 class Config implements \ArrayAccess
 37 {
 38     /**
 39      * An array containing all the options for this config.
 40      *
 41      * @ignore Do not show in PHPDoc.
 42      *
 43      * @var array
 44      */
 45     protected $options = array();
 46 
 47     /**
 48      * Clears the config.
 49      */
 50     public function clear()
 51     {
 52         $this->options = array();
 53     }
 54 
 55     /**
 56      * Returns true whether the field exists.
 57      *
 58      * @param mixed $offset field
 59      *
 60      * @return bool
 61      */
 62     public function offsetExists($offset)
 63     {
 64         return isset($this->options[$offset]);
 65     }
 66 
 67     /**
 68      * Used to get the value of a field.
 69      *
 70      * @param mixed $offset field
 71      *
 72      * @return mixed
 73      */
 74     public function offsetGet($offset)
 75     {
 76         if (!$this->offsetExists($offset)) {
 77             return;
 78         }
 79 
 80         return $this->options[$offset];
 81     }
 82 
 83     /**
 84      * Used to set a value to a field.
 85      *
 86      * @param mixed $offset field
 87      * @param mixed $value  value
 88      */
 89     public function offsetSet($offset, $value)
 90     {
 91         $this->options[$offset] = $value;
 92     }
 93 
 94     /**
 95      * Removes the specified field.
 96      *
 97      * @param mixed $offset field
 98      */
 99     public function offsetUnset($offset)
100     {
101         unset($this->options[$offset]);
102     }
103 }
104 
API documentation generated by ApiGen