/** * @param array $setTuples * @param int $countTuples * * @return array * * @throws \InvalidArgumentException */ private function validateTuples(array $setTuples, $countTuples) { Assert::notEq(0, $countTuples, 'The set builder requires a single array of one or more array sets.1'); foreach ($setTuples as $tuple) { Assert::isArray($tuple, 'The set builder requires a single array of one or more array sets.'); } return $setTuples; }
/** * @param string $directory * * @return \Swift_Message[] */ private function getMessages($directory) { $finder = new Finder(); $finder->files()->name('*.message')->in($directory); Assert::notEq($finder->count(), 0, sprintf('No message files found in %s.', $directory)); $messages = []; /** @var SplFileInfo $file */ foreach ($finder as $file) { $messages[] = unserialize($file->getContents()); } return $messages; }
/** * {@inheritdoc} */ public function remove($query, $language = 'glob') { $resources = $this->find($query, $language); $nbOfResources = count($this->resources); // Run the assertion after find(), so that we know that $query is valid Assert::notEq('', trim($query, '/'), 'The root directory cannot be removed.'); foreach ($resources as $resource) { $this->removeResource($resource); } return $nbOfResources - count($this->resources); }
/** * {@inheritdoc} */ public function remove($query, $language = 'glob') { $iterator = $this->getGlobIterator($query, $language); $removed = 0; Assert::notEq('', trim($query, '/'), 'The root directory cannot be removed.'); // There's some problem with concurrent deletions at the moment foreach (iterator_to_array($iterator) as $filesystemPath) { $this->removeResource($filesystemPath, $removed); } return $removed; }