PHPSocialNetwork/phpfastcache

View on GitHub

Showing 66 of 67 total issues

Method getInstance has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function getInstance(string $driver, ?ConfigurationOptionInterface $config = null, ?string $instanceId = null): ExtendedCacheItemPoolInterface
    {
        if (\class_exists($driver) && \str_starts_with($driver, 'Phpfastcache')) {
            $driverClass = $driver;
        } else {
Severity: Minor
Found in lib/Phpfastcache/CacheManager.php - About 1 hr to fix

    Method driverWrite has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function driverWrite(ExtendedCacheItemInterface $item): bool
        {
    
            try {
                $cacheData = $this->encode($this->driverPreWrap($item));
    Severity: Minor
    Found in lib/Phpfastcache/Drivers/Cassandra/Driver.php - About 1 hr to fix

      Function driverConnect has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function driverConnect(): bool
          {
              $this->instance = new MemcachedSoftware();
              $optPrefix = $this->getConfig()->getOptPrefix();
              $this->instance->setOption(MemcachedSoftware::OPT_BINARY_PROTOCOL, true);
      Severity: Minor
      Found in lib/Phpfastcache/Drivers/Memcached/Driver.php - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method driverConnect has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function driverConnect(): bool
          {
              /**
               * In case of a user-provided
               * Predis client just return here
      Severity: Minor
      Found in lib/Phpfastcache/Drivers/Predis/Driver.php - About 1 hr to fix

        Method getStats has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getStats(): DriverStatistic
            {
                $stats = new DriverStatistic();
                $stats->setInfo(
                    sprintf(
        Severity: Minor
        Found in lib/Phpfastcache/Cluster/ClusterPoolAbstract.php - About 1 hr to fix

          Method getPhpfastcacheVersion has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function getPhpfastcacheVersion(bool $fallbackOnChangelog = true, bool $cacheable = true): string
              {
                  /**
                   * Cache the version statically to improve
                   * performances on multiple calls
          Severity: Minor
          Found in lib/Phpfastcache/Api.php - About 1 hr to fix

            Function getItemsByTags has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getItemsByTags(array $tagNames, int $strategy = TaggableCacheItemPoolInterface::TAG_STRATEGY_ONE): array
                {
                    $items = [];
                    foreach (\array_unique($tagNames) as $tagName) {
                        $items[] = $this->fetchItemsByTagFromBackend($tagName);
            Severity: Minor
            Found in lib/Phpfastcache/Core/Pool/TaggableCacheItemPoolTrait.php - About 1 hr to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function driverConnect has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function driverConnect(): bool
                {
                    $this->instance = new MemcacheSoftware();
            
                    foreach ($this->getConfig()->getServers() as $server) {
            Severity: Minor
            Found in lib/Phpfastcache/Drivers/Memcache/Driver.php - About 1 hr to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function getDriverList has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function getDriverList(bool $fqcnAsKey = false): array
                {
                    static $driverList;
            
                    if (self::getDefaultNamespacePath() === self::getNamespacePath()) {
            Severity: Minor
            Found in lib/Phpfastcache/CacheManager.php - About 1 hr to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Method driverWriteTags has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function driverWriteTags(ExtendedCacheItemInterface $item): bool
                {
                    /**
                     * Do not attempt to write tags
                     * on tags item, it can lead
            Severity: Minor
            Found in lib/Phpfastcache/Core/Pool/TaggableCacheItemPoolTrait.php - About 1 hr to fix

              Method driverConnect has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function driverConnect(): bool
                  {
                      $this->instance = new MemcachedSoftware();
                      $optPrefix = $this->getConfig()->getOptPrefix();
                      $this->instance->setOption(MemcachedSoftware::OPT_BINARY_PROTOCOL, true);
              Severity: Minor
              Found in lib/Phpfastcache/Drivers/Memcached/Driver.php - About 1 hr to fix

                Method getItem has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function getItem(string $key): ExtendedCacheItemInterface
                    {
                        /** @var ExtendedCacheItemPoolInterface[] $poolsToResync */
                        $poolsToResync = [];
                        /** @var ?ExtendedCacheItemInterface $item */
                Severity: Minor
                Found in lib/Phpfastcache/Cluster/Drivers/FullReplication/Driver.php - About 1 hr to fix

                  Method __construct has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function __construct(#[\SensitiveParameter] ConfigurationOptionInterface $config, string $instanceId, EventManagerInterface $em)
                      {
                          $this->setEventManager($em->getScopedEventManager($this));
                          $this->setConfig($config);
                          $this->instanceId = $instanceId;
                  Severity: Minor
                  Found in lib/Phpfastcache/Core/Pool/DriverBaseTrait.php - About 1 hr to fix

                    Method driverConnect has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function driverConnect(): bool
                        {
                            $this->instance = new MemcacheSoftware();
                    
                            foreach ($this->getConfig()->getServers() as $server) {
                    Severity: Minor
                    Found in lib/Phpfastcache/Drivers/Memcache/Driver.php - About 1 hr to fix

                      Method save has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function save(CacheItemInterface $item): bool
                          {
                              $this->assertCacheItemType($item, self::getItemClass());
                              /**
                               * @var ExtendedCacheItemInterface $item
                      Severity: Minor
                      Found in lib/Phpfastcache/Core/Pool/CacheItemPoolTrait.php - About 1 hr to fix

                        Method deleteItems has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function deleteItems(array $keys): bool
                            {
                                if (count($keys) > 1) {
                                    $return = true;
                                    try {
                        Severity: Minor
                        Found in lib/Phpfastcache/Core/Pool/CacheItemPoolTrait.php - About 1 hr to fix

                          Method rrmdir has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public static function rrmdir(string $source, bool $removeOnlyChildren = false): bool
                              {
                                  if (empty($source) || file_exists($source) === false) {
                                      return false;
                                  }
                          Severity: Minor
                          Found in lib/Phpfastcache/Util/Directory.php - About 1 hr to fix

                            Function __call has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function __call(string $name, array $arguments): void
                                {
                                    if (\str_starts_with($name, 'on')) {
                                        $name = \substr($name, 2);
                                        if (\is_callable($arguments[0])) {
                            Severity: Minor
                            Found in lib/Phpfastcache/EventManager.php - About 1 hr to fix

                            Cognitive Complexity

                            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                            A method's cognitive complexity is based on a few simple rules:

                            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                            • Code is considered more complex for each "break in the linear flow of the code"
                            • Code is considered more complex when "flow breaking structures are nested"

                            Further reading

                            Method driverRead has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                protected function driverRead(ExtendedCacheItemInterface $item): ?array
                                {
                                    try {
                                        $stm = $this->getDb($item->getEncodedKey())
                                            ->prepare("SELECT * FROM `caching` WHERE `keyword`=:keyword LIMIT 1");
                            Severity: Minor
                            Found in lib/Phpfastcache/Drivers/Sqlite/Driver.php - About 1 hr to fix

                              Method driverConnect has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  protected function driverConnect(): bool
                                  {
                                      if (isset($this->instance) && $this->instance instanceof RedisClient) {
                                          throw new PhpfastcacheLogicException('Already connected to Redis server');
                                      }
                              Severity: Minor
                              Found in lib/Phpfastcache/Drivers/Redis/Driver.php - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language