@@ -12,8 +12,17 @@ class Cloudinary
1212 const RANGE_RE = '/^(\d+\.)?\d+[%pP]?\.\.(\d+\.)?\d+[%pP]?$/ ' ;
1313
1414 const VERSION = "1.9.0 " ;
15- /** @internal Do not change this value */
16- const USER_AGENT = "CloudinaryPHP/1.9.0 " ;
15+
16+ /**
17+ * Contains information about SDK user agent. Passed to the Cloudinary servers.
18+ *
19+ * Initialized on the first call to {@see self::userAgent()}
20+ *
21+ * Sample value: CloudinaryPHP/1.2.3 (PHP 5.6.7)
22+ *
23+ * @internal Do not change this value
24+ */
25+ private static $ USER_AGENT = "" ;
1726
1827 /**
1928 * Additional information to be passed with the USER_AGENT, e.g. "CloudinaryMagento/1.0.1".
@@ -23,7 +32,7 @@ class Cloudinary
2332 * The format of the value should be <ProductName>/Version[ (comment)].
2433 * @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43
2534 *
26- * <b>Do not set this value in application code!</b>
35+ * @internal <b>Do not set this value in application code!</b>
2736 *
2837 * @var string
2938 */
@@ -32,6 +41,7 @@ class Cloudinary
3241 public static $ DEFAULT_RESPONSIVE_WIDTH_TRANSFORMATION = array ("width " => "auto " , "crop " => "limit " );
3342
3443 private static $ config = null ;
44+
3545 public static $ JS_CONFIG_PARAMS = array (
3646 "api_key " ,
3747 "cloud_name " ,
@@ -41,19 +51,23 @@ class Cloudinary
4151 );
4252
4353 /**
44- * Provides the USER_AGENT string that is passed to the Cloudinary servers.
54+ * Provides the {@see self::$ USER_AGENT} string that is passed to the Cloudinary servers.
4555 *
46- * Prepends {@link $USER_PLATFORM} if it is defined.
56+ * Prepends {@see self:: $USER_PLATFORM} if it is defined.
4757 *
4858 * @return string
4959 */
5060 public static function userAgent ()
5161 {
52- if (self ::$ USER_PLATFORM == "" ) {
53- return self ::USER_AGENT ;
54- } else {
55- return self ::$ USER_PLATFORM . " " . self ::USER_AGENT ;
62+ if (empty (self ::$ USER_AGENT )) {
63+ self ::$ USER_AGENT = 'CloudinaryPHP/ ' . self ::VERSION . ' (PHP ' . PHP_VERSION . ') ' ;
5664 }
65+
66+ if (empty (self ::$ USER_PLATFORM )) {
67+ return self ::$ USER_AGENT ;
68+ }
69+
70+ return self ::$ USER_PLATFORM . ' ' . self ::$ USER_AGENT ;
5771 }
5872
5973 public static function is_not_null ($ var )
0 commit comments