Code Duplication    Length = 16-20 lines in 3 locations

lib/Doctrine/ORM/Tools/Console/Command/ClearCache/CollectionRegionCommand.php 1 location

@@ 99-118 (lines=20) @@
96
            throw new \InvalidArgumentException('Missing arguments "--owner-class" "--association"');
97
        }
98
99
        if ($input->getOption('flush')) {
100
            $collectionRegion  = $cache->getCollectionCacheRegion($ownerClass, $assoc);
101
102
            if ( ! $collectionRegion instanceof DefaultRegion) {
103
                throw new \InvalidArgumentException(sprintf(
104
                    'The option "--flush" expects a "Doctrine\ORM\Cache\Region\DefaultRegion", but got "%s".',
105
                    is_object($collectionRegion) ? get_class($collectionRegion) : gettype($collectionRegion)
106
                ));
107
            }
108
109
            $collectionRegion->getCache()->flushAll();
110
111
            $ui->comment(
112
                sprintf(
113
                    'Flushing cache provider configured for <info>"%s#%s"</info>',
114
                    $ownerClass,
115
                    $assoc
116
                )
117
            );
118
119
            return;
120
        }
121

lib/Doctrine/ORM/Tools/Console/Command/ClearCache/EntityRegionCommand.php 1 location

@@ 97-112 (lines=16) @@
94
            throw new \InvalidArgumentException('Invalid argument "--entity-class"');
95
        }
96
97
        if ($input->getOption('flush')) {
98
            $entityRegion  = $cache->getEntityCacheRegion($entityClass);
99
100
            if ( ! $entityRegion instanceof DefaultRegion) {
101
                throw new \InvalidArgumentException(sprintf(
102
                    'The option "--flush" expects a "Doctrine\ORM\Cache\Region\DefaultRegion", but got "%s".',
103
                    is_object($entityRegion) ? get_class($entityRegion) : gettype($entityRegion)
104
                ));
105
            }
106
107
            $entityRegion->getCache()->flushAll();
108
109
            $ui->comment(sprintf('Flushing cache provider configured for entity named <info>"%s"</info>', $entityClass));
110
111
            return;
112
        }
113
114
        if ($input->getOption('all')) {
115
            $ui->comment('Clearing <info>all</info> second-level cache entity regions');

lib/Doctrine/ORM/Tools/Console/Command/ClearCache/QueryRegionCommand.php 1 location

@@ 95-114 (lines=20) @@
92
            throw new \InvalidArgumentException('No second-level cache is configured on the given EntityManager.');
93
        }
94
95
        if ($input->getOption('flush')) {
96
            $queryCache  = $cache->getQueryCache($name);
97
            $queryRegion = $queryCache->getRegion();
98
99
            if ( ! $queryRegion instanceof DefaultRegion) {
100
                throw new \InvalidArgumentException(sprintf(
101
                    'The option "--flush" expects a "Doctrine\ORM\Cache\Region\DefaultRegion", but got "%s".',
102
                    is_object($queryRegion) ? get_class($queryRegion) : gettype($queryRegion)
103
                ));
104
            }
105
106
            $queryRegion->getCache()->flushAll();
107
108
            $ui->comment(
109
                sprintf(
110
                    'Flushing cache provider configured for second-level cache query region named <info>"%s"</info>',
111
                    $name
112
                )
113
            );
114
115
            return;
116
        }
117