< Summary

Class:DCL.Helpers.PlayerPrefsUtils
Assembly:Utils
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Helpers/Utils/PlayerPrefsUtils.cs
Covered lines:5
Uncovered lines:17
Coverable lines:22
Total lines:54
Line coverage:22.7% (5 of 22)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
GetInt(...)0%2100%
GetInt(...)0%2100%
GetBool(...)0%330100%
SetBool(...)0%330100%
SetInt(...)0%2100%
HasKey(...)0%110100%
GetString(...)0%12300%
SetString(...)0%2100%
Save()0%110100%
GetFloat(...)0%2100%
SetFloat(...)0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Helpers/Utils/PlayerPrefsUtils.cs

#LineLine coverage
 1using UnityEngine;
 2
 3namespace DCL.Helpers
 4{
 5    public static class PlayerPrefsUtils
 6    {
 07        public static int GetInt(string key) { return PlayerPrefs.GetInt(key); }
 8
 09        public static int GetInt(string key, int defaultValue) { return PlayerPrefs.GetInt(key, defaultValue); }
 10
 576911        public static bool GetBool(string key, bool defaultValue) => PlayerPrefs.GetInt(key, defaultValue ? 1 : 0) == 1;
 12
 13        public static void SetBool(string key, bool value)
 14        {
 915            PlayerPrefs.SetInt(key, value ? 1 : 0);
 916        }
 17
 18        public static void SetInt(string key, int value)
 19        {
 20            try
 21            {
 022                PlayerPrefs.SetInt(key, value);
 023            }
 024            catch (PlayerPrefsException e)
 25            {
 026                Debug.Log("There was an issue setting PlayerPrefs int!");
 027            }
 028        }
 29
 192330        public static bool HasKey(string key) { return PlayerPrefs.HasKey(key); }
 31
 032        public static string GetString(string key, string defaultValue = null) { return PlayerPrefs.GetString(key, strin
 33
 34        public static void SetString(string key, string value)
 35        {
 36            try
 37            {
 038                PlayerPrefs.SetString(key, value);
 039            }
 040            catch (PlayerPrefsException e)
 41            {
 042                Debug.Log("There was an issue setting PlayerPrefs string!");
 043            }
 044        }
 45
 246        public static void Save() { PlayerPrefs.Save(); }
 47
 48        public static float GetFloat(string key, float defaultValue = 0f) =>
 049            PlayerPrefs.GetFloat(key, defaultValue);
 50
 51        public static void SetFloat(string key, float value) =>
 052            PlayerPrefs.SetFloat(key, value);
 53    }
 54}