]> git.mxchange.org Git - friendica-addons.git/blobdiff - twitter/vendor/abraham/twitteroauth/src/Util/JsonDecoder.php
Add explicit dependencies to twitter addon
[friendica-addons.git] / twitter / vendor / abraham / twitteroauth / src / Util / JsonDecoder.php
diff --git a/twitter/vendor/abraham/twitteroauth/src/Util/JsonDecoder.php b/twitter/vendor/abraham/twitteroauth/src/Util/JsonDecoder.php
new file mode 100644 (file)
index 0000000..c8589c5
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+
+namespace Abraham\TwitterOAuth\Util;
+
+/**
+ * @author louis <louis@systemli.org>
+ */
+class JsonDecoder
+{
+    /**
+     * Decodes a JSON string to stdObject or associative array
+     *
+     * @param string $string
+     * @param bool   $asArray
+     *
+     * @return array|object
+     */
+    public static function decode($string, $asArray)
+    {
+        if (version_compare(PHP_VERSION, '5.4.0', '>=') && !(defined('JSON_C_VERSION') && PHP_INT_SIZE > 4)) {
+            return json_decode($string, $asArray, 512, JSON_BIGINT_AS_STRING);
+        }
+
+        return json_decode($string, $asArray);
+    }
+}