/** * Should the file object be accepted. * * @param splFileInfo $file * @return Boolean */ public function accept(splFileInfo $file) { if (substr($file->getBaseName(), -strlen($this->ext)) == $this->ext) { return TRUE; } return FALSE; }
protected function addFile(\Phar $phar, \splFileInfo $file, $strip = true) { $path = str_replace(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR, '', $file->getRealPath()); $content = file_get_contents($file); if ($strip) { $content = self::stripWhitespace($content); } $phar->addFromString($path, $content); }
public function getMetricFromFile(\splFileInfo $file) { $codeLines = 0; $blankLines = 0; foreach ($file->openFile() as $line) { if (preg_match('/^\\s+$/', $line)) { $blankLines++; } else { $codeLines++; } } $totalLines = $codeLines + $blankLines; return $totalLines === 0 ? 0 : ($blankLines / $totalLines <= 0.25 ? $totalLines : $codeLines); }
public function interimAttachmentCheck(\splFileInfo $attachment, \CentralApps\Mail\Message $message) { $errors = array(); $preexisting_attatchments = $message->getAttachments(); $existing_size = $this->getAttachmentsSize($preexisting_attatchments); if ($attachment->getSize() + $existing_size > $this->maxAttachmentSize) { $errors[] = "Attachments too large, you have exceeded the attachment size limit for PostMarkApp"; } if (count($preexisting_attatchments) + 1 > $this->maxNumAttachments) { $errors[] = "Too many attachments. Postmark app only permits " . $this->maxNumAttachments . " attachments per message"; } if (!$this->attachmentCheckFileTypes($attachment)) { $errors[] = "The attachment " . $attachment->getFilename() . " is not permitted to be sent via PostMarkApp"; } return $errors; }
public function getMetricFromFile(\splFileInfo $file) { return $file->getSize(); }