_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q251500
Generator.getPhone
validation
public function getPhone($state_code = null, $zip = null, $include_toll_free = false) { if (!empty($zip)) { $areacodes = Zipcode::where('zip', $zip)->orderByRaw(Database::random())->first()->area_codes; } else { // Get a random state if state not provided $state_code = !empty($state_code) ? $state_code : $this->getState()->code; // Get area codes appropriate for this state $areacodes = Zipcode::where('state_code', $state_code)->orderByRaw(Database::random())->first()->area_codes; } // Get list of valid area codes for the state/zip code $code_list = explode(',', $areacodes); // @codeCoverageIgnoreStart // Add some toll free numbers into the mix. if ($include_toll_free === true) { $code_list[] = 800; $code_list[] = 888; $code_list[] = 877; $code_list[] = 866; $code_list[] = 855; } // @codeCoverageIgnoreEnd // Get a random area code from valid area codes $areacode = $this->fromArray($code_list); $prefix = rand(100, 999); $number = rand(1, 9999); return $areacode . '-' . $prefix . '-' . str_pad($number, 4, '0', STR_PAD_LEFT); }
php
{ "resource": "" }
q251501
Generator.getIp
validation
public function getIp() { $parts = []; for ($i=0; $i<4; $i++) { $parts[] = $this->getInteger(0, 255); } return join('.', $parts); }
php
{ "resource": "" }
q251502
Generator.getEmail
validation
public function getEmail($person_name = null, $domain = null) { $username = $this->getUsername($person_name); $domains = []; $domains[] = !empty($domain) ? $domain : $this->getDomain(); $domains[] = 'gmail.com'; $domains[] = 'yahoo.com'; $domains[] = 'me.com'; $domains[] = 'msn.com'; $domains[] = 'hotmail.com'; $domain = $this->fromArray($domains); return preg_replace('/[^0-9a-z_A-Z.]/', '', strtolower($username)) . '@' . $domain; }
php
{ "resource": "" }
q251503
Generator.getInternet
validation
public function getInternet($person_name = null, $company = null) { if (empty($person_name)) { $person_name = $this->getFullName(); } $internet = new Entities\Internet(); $internet->domain = $this->getDomain($company); $internet->username = $this->getUserName($person_name); $internet->email = $this->getEmail($person_name, $internet->domain); $internet->url = $this->getUrl($internet->domain); $internet->ip = $this->getIp(); return $internet; }
php
{ "resource": "" }
q251504
Generator.getCreditCard
validation
public function getCreditCard($weighted = true) { // Get a random card type if ($weighted) { $weight[] = ['American Express', 1]; $weight[] = ['Discover', 2]; $weight[] = ['MasterCard', 10]; $weight[] = ['Visa', 10]; foreach ($weight as $w) { $type = $w[0]; $count = $w[1]; for ($i=0; $i<$count; $i++) { $card_types[] = $type; } } } else { // @codeCoverageIgnoreStart $card_types = ['American Express', 'Discover', 'MasterCard', 'Visa']; // @codeCoverageIgnoreEnd } $cc = new Entities\CreditCard; $cc->type = $this->fromArray($card_types); // Get a random card number appropriate for this type that passes Luhn/Mod10 check $cc->number = $this->getBankNumber($cc->type); // Get an expiration date $cc->expiration = $this->getExpiration(); return $cc; }
php
{ "resource": "" }
q251505
Generator.getBank
validation
public function getBank() { $bank_account = new Entities\BankAccount; $bank_account->type = $this->fromArray(['Checking', 'Savings']); $bank_account->name = $this->fromArray(['First National', 'Arvest', 'Regions', 'Metropolitan', 'Wells Fargo']); $bank_account->account = $this->getInteger('1000', '999999999'); $bank_account->routing = $this->getBankNumber('Routing'); return $bank_account; }
php
{ "resource": "" }
q251506
Generator.getPerson
validation
public function getPerson($state_code = null) { $state_code = !empty($state_code) ? $state_code : $this->getState()->code; $person = new Entities\Person; $person->guid = $this->getGuid(); $person->unique_hash = $this->getUniqueHash(); $person->name = $this->getFullName(); // Returns an object with first, middle, last, and gender properties // @codeCoverageIgnoreStart if (rand(1, 100) % 5 == 0) { // Self employed? Name the business after them. $person->company = $this->getCompanyName($person->name->last); } else { // Generate some random company name. $person->company = $this->getCompanyName(); } // @codeCoverageIgnoreEnd # Primary address $person->address = $this->getAddress($state_code); # Secondary Address. Mailing Address? Use same zip code and primary address $person->address2 = $this->getAddress($state_code, $person->address->zip); $person->internet = $this->getInternet($person->name, $person->company); # Everyone has at least 2 or three phone numbers $person->phone = new stdclass(); $person->phone->home = $this->getPhone($state_code, $person->address->zip); $person->phone->mobile = $this->getPhone($state_code, $person->address->zip); $person->phone->work = $this->getPhone($state_code, $person->address->zip); $person->ssn = $this->getSsn($state_code); $person->dln = $this->getDln($state_code); $person->dob = $this->getBirthDate(); # Payment Implements $person->credit_card = $this->getCreditCard(); $person->bank_account = $this->getBank(); return $person; }
php
{ "resource": "" }
q251507
Fill.setRotation
validation
public function setRotation($pValue) { if ($this->isSupervisor) { $styleArray = $this->getStyleArray(['rotation' => $pValue]); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); } else { $this->rotation = $pValue; } return $this; }
php
{ "resource": "" }
q251508
Fill.setEndColor
validation
public function setEndColor(Color $pValue) { // make sure parameter is a real color and not a supervisor $color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue; if ($this->isSupervisor) { $styleArray = $this->getEndColor()->getStyleArray(['argb' => $color->getARGB()]); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); } else { $this->endColor = $color; } return $this; }
php
{ "resource": "" }
q251509
MailingsService.createMailing
validation
function createMailing($name, $subject, $deprecatedParameter = false, $type = "regular") { $queryParameters = array( 'name' => urlencode($name), 'subject' => urlencode($subject), 'type' => urlencode($type), ); return $this->post('mailings', "", $queryParameters); }
php
{ "resource": "" }
q251510
MailingsService.setHTMLContent
validation
function setHTMLContent($mailingId, $html, $doImageGrabbing = true, $doLinkTracking = false) { $queryParameters = array( 'doImageGrabbing' => ($doImageGrabbing == TRUE) ? "true" : "false", 'doLinkTracking' => ($doLinkTracking == TRUE) ? "true" : "false" ); return $this->post('mailings/' . $mailingId . '/contents/html', $html, $queryParameters, "text/html"); }
php
{ "resource": "" }
q251511
MailingsService.setReplyToAddress
validation
function setReplyToAddress($mailingId, $auto = true, $customEmail = null) { $queryParameters = array( 'auto' => ($auto == TRUE) ? "true" : "false", 'customEmail' => $customEmail ); return $this->post('mailings/' . $mailingId . '/settings/replyto', null, $queryParameters); }
php
{ "resource": "" }
q251512
MailingsService.addAttachment
validation
function addAttachment($mailingId, $filename, $contentType, $contents) { $queryParameters = array( 'filename' => $filename ); return $this->post("mailings/${mailingId}/attachments", $contents, $queryParameters, null, null, $contentType, strlen($contents)); }
php
{ "resource": "" }
q251513
MailingsService.addCustomProperties
validation
function addCustomProperties($mailingId, $properties) { $xml = new SimpleXMLElement("<?xml version=\"1.0\"?><properties></properties>"); if (is_array($properties)) { foreach ($properties as $property) { $this->sxml_append($xml, $property->toXML()); } } else { $this->sxml_append($xml, $properties->toXML()); } return $this->post("mailings/${mailingId}/settings/properties", $xml->asXML()); }
php
{ "resource": "" }
q251514
MailingsService.updateCustomProperty
validation
function updateCustomProperty($mailingId, $property) { $queryParameters = array( 'name' => $property->key, 'value' => $property->value ); return $this->put("mailings/${mailingId}/settings/properties", "", $queryParameters); }
php
{ "resource": "" }
q251515
Protection.setLocked
validation
public function setLocked($pValue) { if ($this->isSupervisor) { $styleArray = $this->getStyleArray(['locked' => $pValue]); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); } else { $this->locked = $pValue; } return $this; }
php
{ "resource": "" }
q251516
Font.getTextWidthPixelsExact
validation
public static function getTextWidthPixelsExact($text, \PhpOffice\PhpSpreadsheet\Style\Font $font, $rotation = 0) { if (!function_exists('imagettfbbox')) { throw new PhpSpreadsheetException('GD library needs to be enabled'); } // font size should really be supplied in pixels in GD2, // but since GD2 seems to assume 72dpi, pixels and points are the same $fontFile = self::getTrueTypeFontFileFromFont($font); $textBox = imagettfbbox($font->getSize(), $rotation, $fontFile, $text); // Get corners positions $lowerLeftCornerX = $textBox[0]; $lowerRightCornerX = $textBox[2]; $upperRightCornerX = $textBox[4]; $upperLeftCornerX = $textBox[6]; // Consider the rotation when calculating the width $textWidth = max($lowerRightCornerX - $upperLeftCornerX, $upperRightCornerX - $lowerLeftCornerX); return $textWidth; }
php
{ "resource": "" }
q251517
Font.getTextWidthPixelsApprox
validation
public static function getTextWidthPixelsApprox($columnText, \PhpOffice\PhpSpreadsheet\Style\Font $font, $rotation = 0) { $fontName = $font->getName(); $fontSize = $font->getSize(); // Calculate column width in pixels. We assume fixed glyph width. Result varies with font name and size. switch ($fontName) { case 'Calibri': // value 8.26 was found via interpolation by inspecting real Excel files with Calibri 11 font. $columnWidth = (int) (8.26 * StringHelper::countCharacters($columnText)); $columnWidth = $columnWidth * $fontSize / 11; // extrapolate from font size break; case 'Arial': // value 8 was set because of experience in different exports at Arial 10 font. $columnWidth = (int) (8 * StringHelper::countCharacters($columnText)); $columnWidth = $columnWidth * $fontSize / 10; // extrapolate from font size break; case 'Verdana': // value 8 was found via interpolation by inspecting real Excel files with Verdana 10 font. $columnWidth = (int) (8 * StringHelper::countCharacters($columnText)); $columnWidth = $columnWidth * $fontSize / 10; // extrapolate from font size break; default: // just assume Calibri $columnWidth = (int) (8.26 * StringHelper::countCharacters($columnText)); $columnWidth = $columnWidth * $fontSize / 11; // extrapolate from font size break; } // Calculate approximate rotated column width if ($rotation !== 0) { if ($rotation == -165) { // stacked text $columnWidth = 4; // approximation } else { // rotated text $columnWidth = $columnWidth * cos(deg2rad($rotation)) + $fontSize * abs(sin(deg2rad($rotation))) / 5; // approximation } } // pixel width is an integer return (int) $columnWidth; }
php
{ "resource": "" }
q251518
Font.getDefaultRowHeightByFont
validation
public static function getDefaultRowHeightByFont(\PhpOffice\PhpSpreadsheet\Style\Font $font) { switch ($font->getName()) { case 'Arial': switch ($font->getSize()) { case 10: // inspection of Arial 10 workbook says 12.75pt ~17px $rowHeight = 12.75; break; case 9: // inspection of Arial 9 workbook says 12.00pt ~16px $rowHeight = 12; break; case 8: // inspection of Arial 8 workbook says 11.25pt ~15px $rowHeight = 11.25; break; case 7: // inspection of Arial 7 workbook says 9.00pt ~12px $rowHeight = 9; break; case 6: case 5: // inspection of Arial 5,6 workbook says 8.25pt ~11px $rowHeight = 8.25; break; case 4: // inspection of Arial 4 workbook says 6.75pt ~9px $rowHeight = 6.75; break; case 3: // inspection of Arial 3 workbook says 6.00pt ~8px $rowHeight = 6; break; case 2: case 1: // inspection of Arial 1,2 workbook says 5.25pt ~7px $rowHeight = 5.25; break; default: // use Arial 10 workbook as an approximation, extrapolation $rowHeight = 12.75 * $font->getSize() / 10; break; } break; case 'Calibri': switch ($font->getSize()) { case 11: // inspection of Calibri 11 workbook says 15.00pt ~20px $rowHeight = 15; break; case 10: // inspection of Calibri 10 workbook says 12.75pt ~17px $rowHeight = 12.75; break; case 9: // inspection of Calibri 9 workbook says 12.00pt ~16px $rowHeight = 12; break; case 8: // inspection of Calibri 8 workbook says 11.25pt ~15px $rowHeight = 11.25; break; case 7: // inspection of Calibri 7 workbook says 9.00pt ~12px $rowHeight = 9; break; case 6: case 5: // inspection of Calibri 5,6 workbook says 8.25pt ~11px $rowHeight = 8.25; break; case 4: // inspection of Calibri 4 workbook says 6.75pt ~9px $rowHeight = 6.75; break; case 3: // inspection of Calibri 3 workbook says 6.00pt ~8px $rowHeight = 6.00; break; case 2: case 1: // inspection of Calibri 1,2 workbook says 5.25pt ~7px $rowHeight = 5.25; break; default: // use Calibri 11 workbook as an approximation, extrapolation $rowHeight = 15 * $font->getSize() / 11; break; } break; case 'Verdana': switch ($font->getSize()) { case 10: // inspection of Verdana 10 workbook says 12.75pt ~17px $rowHeight = 12.75; break; case 9: // inspection of Verdana 9 workbook says 11.25pt ~15px $rowHeight = 11.25; break; case 8: // inspection of Verdana 8 workbook says 10.50pt ~14px $rowHeight = 10.50; break; case 7: // inspection of Verdana 7 workbook says 9.00pt ~12px $rowHeight = 9.00; break; case 6: case 5: // inspection of Verdana 5,6 workbook says 8.25pt ~11px $rowHeight = 8.25; break; case 4: // inspection of Verdana 4 workbook says 6.75pt ~9px $rowHeight = 6.75; break; case 3: // inspection of Verdana 3 workbook says 6.00pt ~8px $rowHeight = 6; break; case 2: case 1: // inspection of Verdana 1,2 workbook says 5.25pt ~7px $rowHeight = 5.25; break; default: // use Verdana 10 workbook as an approximation, extrapolation $rowHeight = 12.75 * $font->getSize() / 10; break; } break; default: // just use Calibri as an approximation $rowHeight = 15 * $font->getSize() / 11; break; } return $rowHeight; }
php
{ "resource": "" }
q251519
Styles.write
validation
public function write(Spreadsheet $spreadsheet = null) { $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // XML header $objWriter->startDocument('1.0', 'UTF-8'); // Content $objWriter->startElement('office:document-styles'); $objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'); $objWriter->writeAttribute('xmlns:style', 'urn:oasis:names:tc:opendocument:xmlns:style:1.0'); $objWriter->writeAttribute('xmlns:text', 'urn:oasis:names:tc:opendocument:xmlns:text:1.0'); $objWriter->writeAttribute('xmlns:table', 'urn:oasis:names:tc:opendocument:xmlns:table:1.0'); $objWriter->writeAttribute('xmlns:draw', 'urn:oasis:names:tc:opendocument:xmlns:drawing:1.0'); $objWriter->writeAttribute('xmlns:fo', 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0'); $objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink'); $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); $objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'); $objWriter->writeAttribute('xmlns:number', 'urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0'); $objWriter->writeAttribute('xmlns:presentation', 'urn:oasis:names:tc:opendocument:xmlns:presentation:1.0'); $objWriter->writeAttribute('xmlns:svg', 'urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0'); $objWriter->writeAttribute('xmlns:chart', 'urn:oasis:names:tc:opendocument:xmlns:chart:1.0'); $objWriter->writeAttribute('xmlns:dr3d', 'urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0'); $objWriter->writeAttribute('xmlns:math', 'http://www.w3.org/1998/Math/MathML'); $objWriter->writeAttribute('xmlns:form', 'urn:oasis:names:tc:opendocument:xmlns:form:1.0'); $objWriter->writeAttribute('xmlns:script', 'urn:oasis:names:tc:opendocument:xmlns:script:1.0'); $objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office'); $objWriter->writeAttribute('xmlns:ooow', 'http://openoffice.org/2004/writer'); $objWriter->writeAttribute('xmlns:oooc', 'http://openoffice.org/2004/calc'); $objWriter->writeAttribute('xmlns:dom', 'http://www.w3.org/2001/xml-events'); $objWriter->writeAttribute('xmlns:rpt', 'http://openoffice.org/2005/report'); $objWriter->writeAttribute('xmlns:of', 'urn:oasis:names:tc:opendocument:xmlns:of:1.2'); $objWriter->writeAttribute('xmlns:xhtml', 'http://www.w3.org/1999/xhtml'); $objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#'); $objWriter->writeAttribute('xmlns:tableooo', 'http://openoffice.org/2009/table'); $objWriter->writeAttribute('xmlns:css3t', 'http://www.w3.org/TR/css3-text/'); $objWriter->writeAttribute('office:version', '1.2'); $objWriter->writeElement('office:font-face-decls'); $objWriter->writeElement('office:styles'); $objWriter->writeElement('office:automatic-styles'); $objWriter->writeElement('office:master-styles'); $objWriter->endElement(); return $objWriter->getData(); }
php
{ "resource": "" }
q251520
Coordinate.coordinateFromString
validation
public static function coordinateFromString($pCoordinateString) { if (preg_match('/^([$]?[A-Z]{1,3})([$]?\\d{1,7})$/', $pCoordinateString, $matches)) { return [$matches[1], $matches[2]]; } elseif (self::coordinateIsRange($pCoordinateString)) { throw new Exception('Cell coordinate string can not be a range of cells'); } elseif ($pCoordinateString == '') { throw new Exception('Cell coordinate can not be zero-length string'); } throw new Exception('Invalid cell coordinate ' . $pCoordinateString); }
php
{ "resource": "" }
q251521
Coordinate.absoluteReference
validation
public static function absoluteReference($pCoordinateString) { if (self::coordinateIsRange($pCoordinateString)) { throw new Exception('Cell coordinate string can not be a range of cells'); } // Split out any worksheet name from the reference $worksheet = ''; $cellAddress = explode('!', $pCoordinateString); if (count($cellAddress) > 1) { list($worksheet, $pCoordinateString) = $cellAddress; } if ($worksheet > '') { $worksheet .= '!'; } // Create absolute coordinate if (ctype_digit($pCoordinateString)) { return $worksheet . '$' . $pCoordinateString; } elseif (ctype_alpha($pCoordinateString)) { return $worksheet . '$' . strtoupper($pCoordinateString); } return $worksheet . self::absoluteCoordinate($pCoordinateString); }
php
{ "resource": "" }
q251522
Coordinate.absoluteCoordinate
validation
public static function absoluteCoordinate($pCoordinateString) { if (self::coordinateIsRange($pCoordinateString)) { throw new Exception('Cell coordinate string can not be a range of cells'); } // Split out any worksheet name from the coordinate $worksheet = ''; $cellAddress = explode('!', $pCoordinateString); if (count($cellAddress) > 1) { list($worksheet, $pCoordinateString) = $cellAddress; } if ($worksheet > '') { $worksheet .= '!'; } // Create absolute coordinate list($column, $row) = self::coordinateFromString($pCoordinateString); $column = ltrim($column, '$'); $row = ltrim($row, '$'); return $worksheet . '$' . $column . '$' . $row; }
php
{ "resource": "" }
q251523
Coordinate.splitRange
validation
public static function splitRange($pRange) { // Ensure $pRange is a valid range if (empty($pRange)) { $pRange = self::DEFAULT_RANGE; } $exploded = explode(',', $pRange); $counter = count($exploded); for ($i = 0; $i < $counter; ++$i) { $exploded[$i] = explode(':', $exploded[$i]); } return $exploded; }
php
{ "resource": "" }
q251524
Coordinate.buildRange
validation
public static function buildRange(array $pRange) { // Verify range if (empty($pRange) || !is_array($pRange[0])) { throw new Exception('Range does not contain any information'); } // Build range $imploded = []; $counter = count($pRange); for ($i = 0; $i < $counter; ++$i) { $pRange[$i] = implode(':', $pRange[$i]); } $imploded = implode(',', $pRange); return $imploded; }
php
{ "resource": "" }
q251525
Coordinate.getRangeBoundaries
validation
public static function getRangeBoundaries($pRange) { // Ensure $pRange is a valid range if (empty($pRange)) { $pRange = self::DEFAULT_RANGE; } // Uppercase coordinate $pRange = strtoupper($pRange); // Extract range if (strpos($pRange, ':') === false) { $rangeA = $rangeB = $pRange; } else { list($rangeA, $rangeB) = explode(':', $pRange); } return [self::coordinateFromString($rangeA), self::coordinateFromString($rangeB)]; }
php
{ "resource": "" }
q251526
Coordinate.columnIndexFromString
validation
public static function columnIndexFromString($pString) { // Using a lookup cache adds a slight memory overhead, but boosts speed // caching using a static within the method is faster than a class static, // though it's additional memory overhead static $indexCache = []; if (isset($indexCache[$pString])) { return $indexCache[$pString]; } // It's surprising how costly the strtoupper() and ord() calls actually are, so we use a lookup array rather than use ord() // and make it case insensitive to get rid of the strtoupper() as well. Because it's a static, there's no significant // memory overhead either static $columnLookup = [ 'A' => 1, 'B' => 2, 'C' => 3, 'D' => 4, 'E' => 5, 'F' => 6, 'G' => 7, 'H' => 8, 'I' => 9, 'J' => 10, 'K' => 11, 'L' => 12, 'M' => 13, 'N' => 14, 'O' => 15, 'P' => 16, 'Q' => 17, 'R' => 18, 'S' => 19, 'T' => 20, 'U' => 21, 'V' => 22, 'W' => 23, 'X' => 24, 'Y' => 25, 'Z' => 26, 'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5, 'f' => 6, 'g' => 7, 'h' => 8, 'i' => 9, 'j' => 10, 'k' => 11, 'l' => 12, 'm' => 13, 'n' => 14, 'o' => 15, 'p' => 16, 'q' => 17, 'r' => 18, 's' => 19, 't' => 20, 'u' => 21, 'v' => 22, 'w' => 23, 'x' => 24, 'y' => 25, 'z' => 26, ]; // We also use the language construct isset() rather than the more costly strlen() function to match the length of $pString // for improved performance if (isset($pString[0])) { if (!isset($pString[1])) { $indexCache[$pString] = $columnLookup[$pString]; return $indexCache[$pString]; } elseif (!isset($pString[2])) { $indexCache[$pString] = $columnLookup[$pString[0]] * 26 + $columnLookup[$pString[1]]; return $indexCache[$pString]; } elseif (!isset($pString[3])) { $indexCache[$pString] = $columnLookup[$pString[0]] * 676 + $columnLookup[$pString[1]] * 26 + $columnLookup[$pString[2]]; return $indexCache[$pString]; } } throw new Exception('Column string index can not be ' . ((isset($pString[0])) ? 'longer than 3 characters' : 'empty')); }
php
{ "resource": "" }
q251527
Coordinate.stringFromColumnIndex
validation
public static function stringFromColumnIndex($columnIndex) { static $indexCache = []; if (!isset($indexCache[$columnIndex])) { $indexValue = $columnIndex; $base26 = null; do { $characterValue = ($indexValue % 26) ?: 26; $indexValue = ($indexValue - $characterValue) / 26; $base26 = chr($characterValue + 64) . ($base26 ?: ''); } while ($indexValue > 0); $indexCache[$columnIndex] = $base26; } return $indexCache[$columnIndex]; }
php
{ "resource": "" }
q251528
Executor.parseCrontab
validation
protected function parseCrontab( $crontab ) { $lines = preg_split( '(\r\n|\r|\n)', $crontab ); $this->crontab = array(); foreach ( $lines as $line ) { $line = trim( $line ); if ( !empty( $line ) && ( $line[0] !== '#' ) && ( $line[0] !== ';' ) ) { $this->crontab[] = new Cronjob( $line ); } } }
php
{ "resource": "" }
q251529
Executor.getJobsSince
validation
protected function getJobsSince( $time ) { $now = time(); $jobs = array(); // Find rescheduled tasks foreach ( $this->rescheduled as $scheduled => $cronjob ) { if ( $scheduled <= $now ) { $jobs[$scheduled][] = $cronjob; unset( $this->rescheduled[$scheduled] ); } } // Find new jobs defined by their crontable entries foreach ( $this->crontab as $cronjob ) { $cronjob->iterator->startTime = $time; if ( ( $scheduled = $cronjob->iterator->current() ) < $now ) { $jobs[$scheduled][] = $cronjob; } } ksort( $jobs ); return $jobs; }
php
{ "resource": "" }
q251530
Executor.executeTasks
validation
protected function executeTasks( array $tasks ) { foreach ( $tasks as $scheduled => $taskList ) { foreach ( $taskList as $cronjob ) { if ( ( $task = $this->taskFactory->factory( $cronjob->task, $scheduled, $this->logger ) ) !== false ) { $this->logger->setTask( $task->getId() ); $this->logger->log( 'Start task execution.' ); $status = $task->execute(); switch ( $status ) { case Executor::SUCCESS: $this->logger->log( 'Finished task execution.' ); break; case Executor::ERROR: $this->logger->log( 'Error occured during task execution.', Logger::WARNING ); break; case Executor::RESCHEDULE: $this->logger->log( 'Task will be rescheduled for ' . $task->reScheduleTime . ' seconds.' ); $this->rescheduled[$scheduled + $task->reScheduleTime] = $cronjob; break; default: $this->logger->log( 'Invalid status returned by task.', Logger::ERROR ); break; } $this->logger->setTask(); } } } }
php
{ "resource": "" }
q251531
Executor.storeLastRun
validation
protected function storeLastRun() { // Silence warnings, which might be caused by multiple possible // failures. We handle and log them anyways. if ( !@file_put_contents( $this->lockDir . '/lastRun', time() ) ) { $this->logger->log( 'Failure storing last run time: ' . ( isset( $php_errormsg ) ? $php_errormsg : 'Unknown error - enable the track_errors ini directive.' ), Logger::ERROR ); return; } $this->logger->log( 'Stored last run time.', Logger::INFO ); }
php
{ "resource": "" }
q251532
Executor.aquireLock
validation
protected function aquireLock() { $lockfile = $this->lockDir . '/lock'; // Silence call, since PHP will issue a warning when the file exists. // But there is no other way to properly immediately create a lock file // only if it does not exist yet. $fp = @fopen( $lockfile, 'x' ); if ( $fp === false ) { // Aquiring the lock failed. $this->logger->log( sprintf( 'The lockfile %s does already exist.', $lockfile ), Logger::WARNING ); return false; } // Store the lock aquiring time in the lock file so this can be // debugged more easily and maybe automotically released after // stallement. fwrite( $fp, time() ); fclose( $fp ); $this->logger->log( 'Aquired lock.', Logger::INFO ); return true; }
php
{ "resource": "" }
q251533
Date.setDefaultTimezone
validation
public static function setDefaultTimezone($timeZone) { if ($timeZone = self::validateTimeZone($timeZone)) { self::$defaultTimeZone = $timeZone; return true; } return false; }
php
{ "resource": "" }
q251534
Date.validateTimeZone
validation
protected static function validateTimeZone($timeZone) { if (is_object($timeZone) && $timeZone instanceof DateTimeZone) { return $timeZone; } elseif (is_string($timeZone)) { return new DateTimeZone($timeZone); } throw new \Exception('Invalid timezone'); }
php
{ "resource": "" }
q251535
Date.excelToTimestamp
validation
public static function excelToTimestamp($excelTimestamp, $timeZone = null) { return (int) self::excelToDateTimeObject($excelTimestamp, $timeZone) ->format('U'); }
php
{ "resource": "" }
q251536
Date.dayStringToNumber
validation
public static function dayStringToNumber($day) { $strippedDayValue = (str_replace(self::$numberSuffixes, '', $day)); if (is_numeric($strippedDayValue)) { return (int) $strippedDayValue; } return $day; }
php
{ "resource": "" }
q251537
Chart.writeChart
validation
public function writeChart(\PhpOffice\PhpSpreadsheet\Chart\Chart $pChart, $calculateCellValues = true) { $this->calculateCellValues = $calculateCellValues; // Create XML writer $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { $objWriter = new XMLWriter(XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { $objWriter = new XMLWriter(XMLWriter::STORAGE_MEMORY); } // Ensure that data series values are up-to-date before we save if ($this->calculateCellValues) { $pChart->refresh(); } // XML header $objWriter->startDocument('1.0', 'UTF-8', 'yes'); // c:chartSpace $objWriter->startElement('c:chartSpace'); $objWriter->writeAttribute('xmlns:c', 'http://schemas.openxmlformats.org/drawingml/2006/chart'); $objWriter->writeAttribute('xmlns:a', 'http://schemas.openxmlformats.org/drawingml/2006/main'); $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); $objWriter->startElement('c:date1904'); $objWriter->writeAttribute('val', 0); $objWriter->endElement(); $objWriter->startElement('c:lang'); $objWriter->writeAttribute('val', 'en-GB'); $objWriter->endElement(); $objWriter->startElement('c:roundedCorners'); $objWriter->writeAttribute('val', 0); $objWriter->endElement(); $this->writeAlternateContent($objWriter); $objWriter->startElement('c:chart'); $this->writeTitle($objWriter, $pChart->getTitle()); $objWriter->startElement('c:autoTitleDeleted'); $objWriter->writeAttribute('val', 0); $objWriter->endElement(); $this->writePlotArea($objWriter, $pChart->getWorksheet(), $pChart->getPlotArea(), $pChart->getXAxisLabel(), $pChart->getYAxisLabel(), $pChart->getChartAxisX(), $pChart->getChartAxisY(), $pChart->getMajorGridlines(), $pChart->getMinorGridlines()); $this->writeLegend($objWriter, $pChart->getLegend()); $objWriter->startElement('c:plotVisOnly'); $objWriter->writeAttribute('val', 1); $objWriter->endElement(); $objWriter->startElement('c:dispBlanksAs'); $objWriter->writeAttribute('val', 'gap'); $objWriter->endElement(); $objWriter->startElement('c:showDLblsOverMax'); $objWriter->writeAttribute('val', 0); $objWriter->endElement(); $objWriter->endElement(); $this->writePrintSettings($objWriter); $objWriter->endElement(); // Return return $objWriter->getData(); }
php
{ "resource": "" }
q251538
Chart.writeTitle
validation
private function writeTitle(XMLWriter $objWriter, Title $title = null) { if ($title === null) { return; } $objWriter->startElement('c:title'); $objWriter->startElement('c:tx'); $objWriter->startElement('c:rich'); $objWriter->startElement('a:bodyPr'); $objWriter->endElement(); $objWriter->startElement('a:lstStyle'); $objWriter->endElement(); $objWriter->startElement('a:p'); $caption = $title->getCaption(); if ((is_array($caption)) && (count($caption) > 0)) { $caption = $caption[0]; } $this->getParentWriter()->getWriterPart('stringtable')->writeRichTextForCharts($objWriter, $caption, 'a'); $objWriter->endElement(); $objWriter->endElement(); $objWriter->endElement(); $this->writeLayout($objWriter, $title->getLayout()); $objWriter->startElement('c:overlay'); $objWriter->writeAttribute('val', 0); $objWriter->endElement(); $objWriter->endElement(); }
php
{ "resource": "" }
q251539
Chart.writeLegend
validation
private function writeLegend(XMLWriter $objWriter, Legend $legend = null) { if ($legend === null) { return; } $objWriter->startElement('c:legend'); $objWriter->startElement('c:legendPos'); $objWriter->writeAttribute('val', $legend->getPosition()); $objWriter->endElement(); $this->writeLayout($objWriter, $legend->getLayout()); $objWriter->startElement('c:overlay'); $objWriter->writeAttribute('val', ($legend->getOverlay()) ? '1' : '0'); $objWriter->endElement(); $objWriter->startElement('c:txPr'); $objWriter->startElement('a:bodyPr'); $objWriter->endElement(); $objWriter->startElement('a:lstStyle'); $objWriter->endElement(); $objWriter->startElement('a:p'); $objWriter->startElement('a:pPr'); $objWriter->writeAttribute('rtl', 0); $objWriter->startElement('a:defRPr'); $objWriter->endElement(); $objWriter->endElement(); $objWriter->startElement('a:endParaRPr'); $objWriter->writeAttribute('lang', 'en-US'); $objWriter->endElement(); $objWriter->endElement(); $objWriter->endElement(); $objWriter->endElement(); }
php
{ "resource": "" }
q251540
Chart.writeDataLabels
validation
private function writeDataLabels(XMLWriter $objWriter, Layout $chartLayout = null) { $objWriter->startElement('c:dLbls'); $objWriter->startElement('c:showLegendKey'); $showLegendKey = (empty($chartLayout)) ? 0 : $chartLayout->getShowLegendKey(); $objWriter->writeAttribute('val', ((empty($showLegendKey)) ? 0 : 1)); $objWriter->endElement(); $objWriter->startElement('c:showVal'); $showVal = (empty($chartLayout)) ? 0 : $chartLayout->getShowVal(); $objWriter->writeAttribute('val', ((empty($showVal)) ? 0 : 1)); $objWriter->endElement(); $objWriter->startElement('c:showCatName'); $showCatName = (empty($chartLayout)) ? 0 : $chartLayout->getShowCatName(); $objWriter->writeAttribute('val', ((empty($showCatName)) ? 0 : 1)); $objWriter->endElement(); $objWriter->startElement('c:showSerName'); $showSerName = (empty($chartLayout)) ? 0 : $chartLayout->getShowSerName(); $objWriter->writeAttribute('val', ((empty($showSerName)) ? 0 : 1)); $objWriter->endElement(); $objWriter->startElement('c:showPercent'); $showPercent = (empty($chartLayout)) ? 0 : $chartLayout->getShowPercent(); $objWriter->writeAttribute('val', ((empty($showPercent)) ? 0 : 1)); $objWriter->endElement(); $objWriter->startElement('c:showBubbleSize'); $showBubbleSize = (empty($chartLayout)) ? 0 : $chartLayout->getShowBubbleSize(); $objWriter->writeAttribute('val', ((empty($showBubbleSize)) ? 0 : 1)); $objWriter->endElement(); $objWriter->startElement('c:showLeaderLines'); $showLeaderLines = (empty($chartLayout)) ? 1 : $chartLayout->getShowLeaderLines(); $objWriter->writeAttribute('val', ((empty($showLeaderLines)) ? 0 : 1)); $objWriter->endElement(); $objWriter->endElement(); }
php
{ "resource": "" }
q251541
Chart.writeBubbles
validation
private function writeBubbles($plotSeriesValues, $objWriter) { if ($plotSeriesValues === null) { return; } $objWriter->startElement('c:bubbleSize'); $objWriter->startElement('c:numLit'); $objWriter->startElement('c:formatCode'); $objWriter->writeRawData('General'); $objWriter->endElement(); $objWriter->startElement('c:ptCount'); $objWriter->writeAttribute('val', $plotSeriesValues->getPointCount()); $objWriter->endElement(); $dataValues = $plotSeriesValues->getDataValues(); if (!empty($dataValues)) { if (is_array($dataValues)) { foreach ($dataValues as $plotSeriesKey => $plotSeriesValue) { $objWriter->startElement('c:pt'); $objWriter->writeAttribute('idx', $plotSeriesKey); $objWriter->startElement('c:v'); $objWriter->writeRawData(1); $objWriter->endElement(); $objWriter->endElement(); } } } $objWriter->endElement(); $objWriter->endElement(); $objWriter->startElement('c:bubble3D'); $objWriter->writeAttribute('val', 0); $objWriter->endElement(); }
php
{ "resource": "" }
q251542
Chart.writeLayout
validation
private function writeLayout(XMLWriter $objWriter, Layout $layout = null) { $objWriter->startElement('c:layout'); if ($layout !== null) { $objWriter->startElement('c:manualLayout'); $layoutTarget = $layout->getLayoutTarget(); if ($layoutTarget !== null) { $objWriter->startElement('c:layoutTarget'); $objWriter->writeAttribute('val', $layoutTarget); $objWriter->endElement(); } $xMode = $layout->getXMode(); if ($xMode !== null) { $objWriter->startElement('c:xMode'); $objWriter->writeAttribute('val', $xMode); $objWriter->endElement(); } $yMode = $layout->getYMode(); if ($yMode !== null) { $objWriter->startElement('c:yMode'); $objWriter->writeAttribute('val', $yMode); $objWriter->endElement(); } $x = $layout->getXPosition(); if ($x !== null) { $objWriter->startElement('c:x'); $objWriter->writeAttribute('val', $x); $objWriter->endElement(); } $y = $layout->getYPosition(); if ($y !== null) { $objWriter->startElement('c:y'); $objWriter->writeAttribute('val', $y); $objWriter->endElement(); } $w = $layout->getWidth(); if ($w !== null) { $objWriter->startElement('c:w'); $objWriter->writeAttribute('val', $w); $objWriter->endElement(); } $h = $layout->getHeight(); if ($h !== null) { $objWriter->startElement('c:h'); $objWriter->writeAttribute('val', $h); $objWriter->endElement(); } $objWriter->endElement(); } $objWriter->endElement(); }
php
{ "resource": "" }
q251543
Chart.writePrintSettings
validation
private function writePrintSettings($objWriter) { $objWriter->startElement('c:printSettings'); $objWriter->startElement('c:headerFooter'); $objWriter->endElement(); $objWriter->startElement('c:pageMargins'); $objWriter->writeAttribute('footer', 0.3); $objWriter->writeAttribute('header', 0.3); $objWriter->writeAttribute('r', 0.7); $objWriter->writeAttribute('l', 0.7); $objWriter->writeAttribute('t', 0.75); $objWriter->writeAttribute('b', 0.75); $objWriter->endElement(); $objWriter->startElement('c:pageSetup'); $objWriter->writeAttribute('orientation', 'portrait'); $objWriter->endElement(); $objWriter->endElement(); }
php
{ "resource": "" }
q251544
BaseWriter.setUseDiskCaching
validation
public function setUseDiskCaching($pValue, $pDirectory = null) { $this->useDiskCaching = $pValue; if ($pDirectory !== null) { if (is_dir($pDirectory)) { $this->diskCachingDirectory = $pDirectory; } else { throw new Exception("Directory does not exist: $pDirectory"); } } return $this; }
php
{ "resource": "" }
q251545
ResolvableFilesystem.resolve
validation
public function resolve($key) { if (!($this->getAdapter() instanceof ResolverInterface)) { throw new \LogicException('This adapter can not resolve keys'); } return $this->getAdapter()->resolve($key); }
php
{ "resource": "" }
q251546
Migrator.recursiveReplace
validation
private function recursiveReplace($path) { $patterns = [ '/*.md', '/*.php', '/*.phtml', '/*.txt', '/*.TXT', ]; $from = array_keys($this->getMapping()); $to = array_values($this->getMapping()); foreach ($patterns as $pattern) { foreach (glob($path . $pattern) as $file) { $original = file_get_contents($file); $converted = str_replace($from, $to, $original); if ($original !== $converted) { echo $file . " converted\n"; file_put_contents($file, $converted); } } } // Do the recursion in subdirectory foreach (glob($path . '/*', GLOB_ONLYDIR) as $subpath) { if (strpos($subpath, $path . '/') === 0) { $this->recursiveReplace($subpath); } } }
php
{ "resource": "" }
q251547
Axis.setLineStyleProperties
validation
public function setLineStyleProperties($line_width = null, $compound_type = null, $dash_type = null, $cap_type = null, $join_type = null, $head_arrow_type = null, $head_arrow_size = null, $end_arrow_type = null, $end_arrow_size = null) { ($line_width !== null) ? $this->lineStyleProperties['width'] = $this->getExcelPointsWidth((float) $line_width) : null; ($compound_type !== null) ? $this->lineStyleProperties['compound'] = (string) $compound_type : null; ($dash_type !== null) ? $this->lineStyleProperties['dash'] = (string) $dash_type : null; ($cap_type !== null) ? $this->lineStyleProperties['cap'] = (string) $cap_type : null; ($join_type !== null) ? $this->lineStyleProperties['join'] = (string) $join_type : null; ($head_arrow_type !== null) ? $this->lineStyleProperties['arrow']['head']['type'] = (string) $head_arrow_type : null; ($head_arrow_size !== null) ? $this->lineStyleProperties['arrow']['head']['size'] = (string) $head_arrow_size : null; ($end_arrow_type !== null) ? $this->lineStyleProperties['arrow']['end']['type'] = (string) $end_arrow_type : null; ($end_arrow_size !== null) ? $this->lineStyleProperties['arrow']['end']['size'] = (string) $end_arrow_size : null; }
php
{ "resource": "" }
q251548
Axis.setGlowProperties
validation
public function setGlowProperties($size, $color_value = null, $color_alpha = null, $color_type = null) { $this->setGlowSize($size) ->setGlowColor( $color_value === null ? $this->glowProperties['color']['value'] : $color_value, $color_alpha === null ? (int) $this->glowProperties['color']['alpha'] : $color_alpha, $color_type === null ? $this->glowProperties['color']['type'] : $color_type ); }
php
{ "resource": "" }
q251549
Axis.setGlowSize
validation
private function setGlowSize($size) { if ($size !== null) { $this->glowProperties['size'] = $this->getExcelPointsWidth($size); } return $this; }
php
{ "resource": "" }
q251550
ReportsService.getOpensCount
validation
function getOpensCount( $fromDate = null, $toDate = null, $mailingIds = null, $contactIds = null, $contactEmails = null, $contactExternalIds = null, $formatFilter = null, $socialNetworkFilter = null, $deviceTypeFilter = null, $excludeAnonymousOpens = false) { $params = $this->createCountQueryParameters($fromDate, $toDate, $contactIds, $contactEmails, $contactExternalIds, $mailingIds, null); if (isset($excludeAnonymousOpens)) $params['exclude_anonymous_opens'] = ($excludeAnonymousOpens == true) ? "true" : "false"; if (isset($formatFilter)) $params['format'] = $formatFilter; $params = $this->appendArrayFields($params, "social_network", $socialNetworkFilter); $params = $this->appendArrayFields($params, "device_type", $deviceTypeFilter); return $this->get('reports/opens/count', $params); }
php
{ "resource": "" }
q251551
ReportsService.getUniqueOpensCount
validation
function getUniqueOpensCount( $fromDate = null, $toDate = null, $mailingIds = null, $contactIds = null, $contactEmails = null, $contactExternalIds = null, $excludeAnonymousOpens = false) { $params = $this->createCountQueryParameters($fromDate, $toDate, $contactIds, $contactEmails, $contactExternalIds, $mailingIds, null); if (isset($excludeAnonymousOpens)) $params['exclude_anonymous_opens'] = ($excludeAnonymousOpens == true) ? "true" : "false"; return $this->get('reports/opens/unique/count', $params); }
php
{ "resource": "" }
q251552
ReportsService.getRecipients
validation
function getRecipients( $fromDate = null, $toDate = null, $mailingIds = null, $contactIds = null, $contactEmails = null, $contactExternalIds = null, $excludeDeletedRecipients = false, $standardFields = null, $customFields = null, $embedFieldBackups = false, $pageIndex = 1, $pageSize = 100) { $params = $this->createQueryParameters($pageIndex, $pageSize, $fromDate, $toDate, $contactIds, $contactEmails, $contactExternalIds, $mailingIds, null, $embedFieldBackups); $params = $this->appendArrayFields($params, "standard_field", $standardFields); $params = $this->appendArrayFields($params, "custom_field", $customFields); if (isset($excludeDeletedRecipients)) $params['exclude_deleted_recipients'] = ($excludeDeletedRecipients == true) ? "true" : "false"; return $this->get('reports/recipients', $params); }
php
{ "resource": "" }
q251553
ReportsService.getRecipientsCount
validation
function getRecipientsCount( $fromDate = null, $toDate = null, $mailingIds = null, $contactIds = null, $contactEmails = null, $contactExternalIds = null, $excludeDeletedRecipients = false) { $params = $this->createCountQueryParameters($fromDate, $toDate, $contactIds, $contactEmails, $contactExternalIds, $mailingIds, null); if (isset($excludeDeletedRecipients)) $params['exclude_deleted_recipients'] = ($excludeDeletedRecipients == true) ? "true" : "false"; return $this->get('reports/recipients/count', $params); }
php
{ "resource": "" }
q251554
ReportsService.getClicks
validation
function getClicks( $fromDate = null, $toDate = null, $mailingIds = null, $contactIds = null, $contactEmails = null, $contactExternalIds = null, $formatFilter = null, $linkIdFilter = null, $linkUrlFilter = null, $linkTagFilter = null, $socialNetworkFilter = null, $deviceTypeFilter = null, $embedEmailClientInfos = false, $excludeAnonymousClicks = false, $standardFields = null, $customFields = null, $embedFieldBackups = false, $pageIndex = 1, $pageSize = 100, $embedLinkTags = false) { $params = $this->createQueryParameters($pageIndex, $pageSize, $fromDate, $toDate, $contactIds, $contactEmails, $contactExternalIds, $mailingIds, null, $embedFieldBackups); $params = $this->appendArrayFields($params, "standard_field", $standardFields); $params = $this->appendArrayFields($params, "custom_field", $customFields); if (isset($embedEmailClientInfos)) $params['embed_email_client_infos'] = ($embedEmailClientInfos == true) ? "true" : "false"; if (isset($embedLinkTags)) $params['embed_link_tags'] = ($embedLinkTags == true) ? "true" : "false"; if (isset($excludeAnonymousClicks)) $params['exclude_anonymous_clicks'] = ($excludeAnonymousClicks == true) ? "true" : "false"; if (isset($formatFilter)) $params['format'] = $formatFilter; $params = $this->appendArrayFields($params, "link_id", $linkIdFilter); if (isset($linkUrlFilter)) $params['link_url'] = $linkUrlFilter; $params = $this->appendArrayFields($params, "link_tag", $linkTagFilter); $params = $this->appendArrayFields($params, "social_network", $socialNetworkFilter); $params = $this->appendArrayFields($params, "device_type", $deviceTypeFilter); return $this->get('reports/clicks', $params); }
php
{ "resource": "" }
q251555
ReportsService.getClicksCount
validation
function getClicksCount( $fromDate = null, $toDate = null, $mailingIds = null, $contactIds = null, $contactEmails = null, $contactExternalIds = null, $formatFilter = null, $linkIdFilter = null, $linkUrlFilter = null, $linkTagFilter = null, $socialNetworkFilter = null, $deviceTypeFilter = null, $excludeAnonymousClicks = false) { $params = $this->createCountQueryParameters($fromDate, $toDate, $contactIds, $contactEmails, $contactExternalIds, $mailingIds, null); if (isset($excludeAnonymousClicks)) $params['exclude_anonymous_clicks'] = ($excludeAnonymousClicks == true) ? "true" : "false"; if (isset($formatFilter)) $params['format'] = $formatFilter; $params = $this->appendArrayFields($params, "link_id", $linkIdFilter); if (isset($linkUrlFilter)) $params['link_url'] = $linkUrlFilter; $params = $this->appendArrayFields($params, "link_tag", $linkTagFilter); $params = $this->appendArrayFields($params, "social_network", $socialNetworkFilter); $params = $this->appendArrayFields($params, "device_type", $deviceTypeFilter); return $this->get('reports/clicks/count', $params); }
php
{ "resource": "" }
q251556
ReportsService.getUniqueClicksCount
validation
function getUniqueClicksCount( $fromDate = null, $toDate = null, $mailingIds = null, $contactIds = null, $contactEmails = null, $contactExternalIds = null, $excludeAnonymousClicks = false) { $params = $this->createCountQueryParameters($fromDate, $toDate, $contactIds, $contactEmails, $contactExternalIds, $mailingIds, null); if (isset($excludeAnonymousClicks)) $params['exclude_anonymous_clicks'] = ($excludeAnonymousClicks == true) ? "true" : "false"; return $this->get('reports/clicks/unique/count', $params); }
php
{ "resource": "" }
q251557
ReportsService.getBouncesCount
validation
function getBouncesCount( $fromDate = null, $toDate = null, $mailingIds = null, $contactIds = null, $contactEmails = null, $contactExternalIds = null, $statusCodeFilter = null, $typeFilter = null, $sourceFilter = null, $excludeAnonymousBounces = false) { $params = $this->createCountQueryParameters($fromDate, $toDate, $contactIds, $contactEmails, $contactExternalIds, $mailingIds, null); if (isset($excludeAnonymousBounces)) $params['exclude_anonymous_bounces'] = ($excludeAnonymousBounces == true) ? "true" : "false"; if (isset($typeFilter)) $params['type'] = $typeFilter; if (isset($sourceFilter)) $params['source_filter'] = $sourceFilter; return $this->get('reports/bounces/count', $params); }
php
{ "resource": "" }
q251558
ReportsService.getUniqueBouncesCount
validation
function getUniqueBouncesCount( $fromDate = null, $toDate = null, $mailingIds = null, $contactIds = null, $contactEmails = null, $contactExternalIds = null, $excludeAnonymousBounces = false) { $params = $this->createCountQueryParameters($fromDate, $toDate, $contactIds, $contactEmails, $contactExternalIds, $mailingIds, null); if (isset($excludeAnonymousBounces)) $params['exclude_anonymous_bounces'] = ($excludeAnonymousBounces == true) ? "true" : "false"; return $this->get('reports/bounces/unique/count', $params); }
php
{ "resource": "" }
q251559
ReportsService.getBlocks
validation
function getBlocks( $fromDate = null, $toDate = null, $contactIds = null, $contactEmails = null, $contactExternalIds = null, $reasons = null, $oldStatus = null, $newStatus = null, $excludeAnonymousBlocks = false, $standardFields = null, $customFields = null, $pageIndex = 1, $pageSize = 100) { $params = $this->createQueryParameters($pageIndex, $pageSize, $fromDate, $toDate, $contactIds, $contactEmails, $contactExternalIds, null, null, null); $params = $this->appendArrayFields($params, "standard_field", $standardFields); $params = $this->appendArrayFields($params, "custom_field", $customFields); if (isset($embedEmailClientInfos)) $params['embed_email_client_infos'] = ($embedEmailClientInfos == true) ? "true" : "false"; if (isset($excludeAnonymousBlocks)) $params['exclude_anonymous_blocks'] = ($excludeAnonymousBlocks == true) ? "true" : "false"; $params = $this->appendArrayFields($params, "reasons", $reasons); if (isset($oldStatus)) $params['old_status'] = $oldStatus; if (isset($newStatus)) $params['new_status'] = $newStatus; return $this->get('reports/blocks', $params); }
php
{ "resource": "" }
q251560
ReportsService.getBlocksCount
validation
function getBlocksCount( $fromDate = null, $toDate = null, $contactIds = null, $contactEmails = null, $contactExternalIds = null, $reasons = null, $oldStatus = null, $newStatus = null, $excludeAnonymousBlocks = false) { $params = $this->createCountQueryParameters($fromDate, $toDate, $contactIds, $contactEmails, $contactExternalIds, null, null); if (isset($excludeAnonymousBlocks)) $params['exclude_anonymous_blocks'] = ($excludeAnonymousBlocks == true) ? "true" : "false"; $params = $this->appendArrayFields($params, "reasons", $reasons); if (isset($oldStatus)) $params['old_status'] = $oldStatus; if (isset($newStatus)) $params['new_status'] = $newStatus; return $this->get('reports/blocks/count', $params); }
php
{ "resource": "" }
q251561
ReportsService.getUnsubscribers
validation
function getUnsubscribers( $fromDate = null, $toDate = null, $mailingIds = null, $contactIds = null, $contactEmails = null, $contactExternalIds = null, $source = null, $embedFieldBackups = false, $pageIndex = 1, $pageSize = 100) { $params = $this->createQueryParameters($pageIndex, $pageSize, $fromDate, $toDate, $contactIds, $contactEmails, $contactExternalIds, $mailingIds, $source, $embedFieldBackups); return $this->get('reports/unsubscriptions', $params); }
php
{ "resource": "" }
q251562
ReportsService.getUnsubscribersCount
validation
function getUnsubscribersCount( $fromDate = null, $toDate = null, $mailingIds = null, $contactIds = null, $contactEmails = null, $contactExternalIds = null, $source = null) { $params = $this->createCountQueryParameters($fromDate, $toDate, $contactIds, $contactEmails, $contactExternalIds, $mailingIds, $source); return $this->get('reports/unsubscriptions/count', $params); }
php
{ "resource": "" }
q251563
ReportsService.getSubscribersCount
validation
function getSubscribersCount($fromDate = null, $toDate = null, $mailingIds = array(), $contactIds = array(), $contactEmails = array(), $contactExternalIds = array(), $excludeAnonymousContacts = false) { $params = $this->createCountQueryParameters($fromDate, $toDate, $contactIds, $contactEmails, $contactExternalIds, $mailingIds, null); if (isset ($excludeAnonymousContacts)) $params ['exclude_anonymous_contacts'] = ($excludeAnonymousContacts == true) ? "true" : "false"; return $this->get('reports/subscribers/count', $params); }
php
{ "resource": "" }
q251564
ReportsService.createQueryParameters
validation
private function createQueryParameters($pageIndex, $pageSize, $fromDate, $toDate, $contactIds, $contactEmails, $contactExternalIds, $mailingIds, $source, $embedFieldBackups) { $queryParameters = array( 'page_index' => $pageIndex, 'page_size' => $pageSize ); if (isset ($fromDate)) $queryParameters ['from_date'] = $fromDate; if (isset ($toDate)) $queryParameters ['to_date'] = $toDate; if (isset ($source)) $queryParameters ['source'] = $source; $queryParameters = $this->appendArrayFields($queryParameters, "ids", $contactIds); $queryParameters = $this->appendArrayFields($queryParameters, "emails", $contactEmails); $queryParameters = $this->appendArrayFields($queryParameters, "eids", $contactExternalIds); if (isset ($embedFieldBackups)) $queryParameters ['embed_field_backups'] = ($embedFieldBackups == true) ? "true" : "false"; if (isset ($mailingIds)) { $queryParameters ['mailing_id'] = array(); foreach ($mailingIds as $mailingId) { $queryParameters ['mailing_id'] [] = $mailingId; } } return $queryParameters; }
php
{ "resource": "" }
q251565
ReportsService.createCountQueryParameters
validation
private function createCountQueryParameters($fromDate, $toDate, $contactIds, $contactEmails, $contactExternalIds, $mailingIds, $source) { $queryParameters = array(); if (isset ($fromDate)) $queryParameters ['from_date'] = $fromDate; if (isset ($toDate)) $queryParameters ['to_date'] = $toDate; if (isset ($source)) $queryParameters ['source'] = $source; $queryParameters = $this->appendArrayFields($queryParameters, "ids", $contactIds); $queryParameters = $this->appendArrayFields($queryParameters, "emails", $contactEmails); $queryParameters = $this->appendArrayFields($queryParameters, "eids", $contactExternalIds); if (isset ($mailingIds)) { $queryParameters ['mailing_id'] = array(); foreach ($mailingIds as $mailingId) { $queryParameters ['mailing_id'] [] = $mailingId; } } return $queryParameters; }
php
{ "resource": "" }
q251566
Db.setOptions
validation
protected function setOptions(array $options) { if (!array_key_exists('adapter', $options) || !array_key_exists('table', $options) || !array_key_exists('column_key', $options) || !array_key_exists('column_value', $options)) { throw new Exception\InvalidArgumentException('Db adapter options must be defined "adapter", "table", "column_key" and "column_value" keys.'); } if (!$options['adapter'] instanceof Adapter) { throw new Exception\InvalidArgumentException('Db adapter must be an instance of Zend\Db\Adapter\Adapter.'); } $this->adapter = $options['adapter']; $options['table'] = $this->adapter->getPlatform()->quoteIdentifier($options['table']); $options['column_key'] = $this->adapter->getPlatform()->quoteIdentifier($options['column_key']); $options['column_value'] = $this->adapter->getPlatform()->quoteIdentifier($options['column_value']); $this->options = $options; return $this; }
php
{ "resource": "" }
q251567
ContactFilter.addRule
validation
function addRule($rule) { if (!$this->rules) $this->rules = array(); array_push($this->rules, $rule); }
php
{ "resource": "" }
q251568
ContactFilter.fromXML
validation
function fromXML($xmlElement) { $this->author = $xmlElement->author; $this->countContacts = $xmlElement->count_contacts; $this->countRules = $xmlElement->count_rules; $this->created = $xmlElement->created; $this->id = $xmlElement->id; $this->name = $xmlElement->name; $this->state = $xmlElement->state; if ($xmlElement->rules) { $rules = $xmlElement->rules; foreach ($rules as $rule) { array_push($this->rules, new Rule($rule->is_customfield, $rule->field, $rule->operator, $rule->value, $rule->type)); } } }
php
{ "resource": "" }
q251569
SpContainer.getNestingLevel
validation
public function getNestingLevel() { $nestingLevel = 0; $parent = $this->getParent(); while ($parent instanceof SpgrContainer) { ++$nestingLevel; $parent = $parent->getParent(); } return $nestingLevel; }
php
{ "resource": "" }
q251570
Image.set_images
validation
public function set_images( $post_id, $post, $update ) { App::setCurrentID( 'EFG' ); if ( Module::CustomImagesGrifus()->getOption( 'replace-when-add' ) ) { $is_insert_post = App::main()->is_after_insert_post( $post, $update ); $is_update_post = App::main()->is_after_update_post( $post, $update ); if ( $is_insert_post || $is_update_post ) { $this->model->set_images( $post_id ); } } }
php
{ "resource": "" }
q251571
Image.replace_when_add
validation
public function replace_when_add() { $state = isset( $_POST['state'] ) ? $_POST['state'] : null; $nonce = isset( $_POST['nonce'] ) ? $_POST['nonce'] : ''; if ( ! wp_verify_nonce( $nonce, 'eliasis' ) && ! wp_verify_nonce( $nonce, 'customImagesGrifusAdmin' ) ) { die( 'Busted!' ); } App::setCurrentID( 'EFG' ); $slug = Module::CustomImagesGrifus()->getOption( 'slug' ); $this->model->set_replace_when_add( $slug, $state ); $response = [ 'replace-when-add' => $state ]; echo json_encode( $response ); die(); }
php
{ "resource": "" }
q251572
VideoEmbed.load
validation
public function load($url) { if (!is_string($url)) { throw new \InvalidArgumentException('The url argument must be of type string'); } $this->url = $url; // Converts PHP errors and warnings to Exceptions set_error_handler(function() { throw new \Exception(func_get_arg(1)); }); $errorReason = ''; try { $urlData = parse_url($this->url); if (isset($urlData['host'])) { $hostname = $urlData['host']; if (substr($hostname, 0, 4) === 'www.') { $hostname = substr($hostname, 4); } foreach (self::$providers as $name => $domains) { $done = false; foreach ($domains as $domain) { if (preg_match('/^' . str_replace(['.', '*'], ['\.', '.*'], $domain) . '$/', $hostname)) { include_once __DIR__ . DIRECTORY_SEPARATOR . 'VideoEmbed' . DIRECTORY_SEPARATOR . 'Internal' . DIRECTORY_SEPARATOR . 'Providers' . DIRECTORY_SEPARATOR . $name . '.php'; call_user_func(['\IvoPetkov\VideoEmbed\Internal\Providers\\' . $name, 'load'], $this->url, $this); $done = true; break; } } if ($done) { break; } } } } catch (\Exception $e) { $errorReason = $e->getMessage(); } restore_error_handler(); if ($this->html === null) { throw new \Exception('Cannot retrieve information about ' . $this->url . ' (reason: ' . (isset($errorReason{0}) ? $errorReason : 'unknown') . ')'); } }
php
{ "resource": "" }
q251573
VideoEmbed.setSize
validation
public function setSize($width, $height) { if (!is_string($width) && !is_int($width)) { throw new \InvalidArgumentException('The width argument must be of type string or integer'); } if (!is_string($height) && !is_int($height)) { throw new \InvalidArgumentException('The height argument must be of type string or integer'); } $this->html = preg_replace("/ width([ ]?)=([ ]?)[\"\']([0-9\.]+)[\"\']/", " width=\"" . $width . "\"", $this->html); $this->html = preg_replace("/ height([ ]?)=([ ]?)[\"\']([0-9\.]+)[\"\']/", " height=\"" . $height . "\"", $this->html); $this->html = preg_replace("/width:([0-9\.]+)px/", "width:" . (is_numeric($width) ? $width . 'px' : $width) . "", $this->html); $this->html = preg_replace("/height:([0-9\.]+)px/", "height:" . (is_numeric($height) ? $height . 'px' : $height) . "", $this->html); $this->html = preg_replace("/ width([ ]?)=([ ]?)([0-9\.]+)/", " width=" . $width, $this->html); $this->html = preg_replace("/ height([ ]?)=([ ]?)([0-9\.]+)/", " height=" . $height, $this->html); $this->width = $width; $this->height = $height; }
php
{ "resource": "" }
q251574
ReportContact.fromXML
validation
function fromXML($xmlElement) { parent::fromXML($xmlElement); if (isset($xmlElement->permissionType)) $this->permission = Permission::getPermission($xmlElement->permissionType); if (isset($xmlElement->field_backups)) $this->fieldBackups = XMLDeserializer::deserialize($xmlElement->field_backups); }
php
{ "resource": "" }
q251575
Font.setName
validation
public function setName($pValue) { if ($pValue == '') { $pValue = 'Calibri'; } if ($this->isSupervisor) { $styleArray = $this->getStyleArray(['name' => $pValue]); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); } else { $this->name = $pValue; } return $this; }
php
{ "resource": "" }
q251576
Font.setSuperscript
validation
public function setSuperscript($pValue) { if ($pValue == '') { $pValue = false; } if ($this->isSupervisor) { $styleArray = $this->getStyleArray(['superscript' => $pValue]); $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray); } else { $this->superscript = $pValue; $this->subscript = !$pValue; } return $this; }
php
{ "resource": "" }
q251577
Xls.getDistanceY
validation
public static function getDistanceY(Worksheet $sheet, $startRow = 1, $startOffsetY = 0, $endRow = 1, $endOffsetY = 0) { $distanceY = 0; // add the widths of the spanning rows for ($row = $startRow; $row <= $endRow; ++$row) { $distanceY += self::sizeRow($sheet, $row); } // correct for offsetX in startcell $distanceY -= (int) floor(self::sizeRow($sheet, $startRow) * $startOffsetY / 256); // correct for offsetX in endcell $distanceY -= (int) floor(self::sizeRow($sheet, $endRow) * (1 - $endOffsetY / 256)); return $distanceY; }
php
{ "resource": "" }
q251578
Xls.oneAnchor2twoAnchor
validation
public static function oneAnchor2twoAnchor($sheet, $coordinates, $offsetX, $offsetY, $width, $height) { list($column, $row) = Coordinate::coordinateFromString($coordinates); $col_start = Coordinate::columnIndexFromString($column); $row_start = $row - 1; $x1 = $offsetX; $y1 = $offsetY; // Initialise end cell to the same as the start cell $col_end = $col_start; // Col containing lower right corner of object $row_end = $row_start; // Row containing bottom right corner of object // Zero the specified offset if greater than the cell dimensions if ($x1 >= self::sizeCol($sheet, Coordinate::stringFromColumnIndex($col_start))) { $x1 = 0; } if ($y1 >= self::sizeRow($sheet, $row_start + 1)) { $y1 = 0; } $width = $width + $x1 - 1; $height = $height + $y1 - 1; // Subtract the underlying cell widths to find the end cell of the image while ($width >= self::sizeCol($sheet, Coordinate::stringFromColumnIndex($col_end))) { $width -= self::sizeCol($sheet, Coordinate::stringFromColumnIndex($col_end)); ++$col_end; } // Subtract the underlying cell heights to find the end cell of the image while ($height >= self::sizeRow($sheet, $row_end + 1)) { $height -= self::sizeRow($sheet, $row_end + 1); ++$row_end; } // Bitmap isn't allowed to start or finish in a hidden cell, i.e. a cell // with zero height or width. if (self::sizeCol($sheet, Coordinate::stringFromColumnIndex($col_start)) == 0) { return; } if (self::sizeCol($sheet, Coordinate::stringFromColumnIndex($col_end)) == 0) { return; } if (self::sizeRow($sheet, $row_start + 1) == 0) { return; } if (self::sizeRow($sheet, $row_end + 1) == 0) { return; } // Convert the pixel values to the percentage value expected by Excel $x1 = $x1 / self::sizeCol($sheet, Coordinate::stringFromColumnIndex($col_start)) * 1024; $y1 = $y1 / self::sizeRow($sheet, $row_start + 1) * 256; $x2 = ($width + 1) / self::sizeCol($sheet, Coordinate::stringFromColumnIndex($col_end)) * 1024; // Distance to right side of object $y2 = ($height + 1) / self::sizeRow($sheet, $row_end + 1) * 256; // Distance to bottom of object $startCoordinates = Coordinate::stringFromColumnIndex($col_start) . ($row_start + 1); $endCoordinates = Coordinate::stringFromColumnIndex($col_end) . ($row_end + 1); $twoAnchor = [ 'startCoordinates' => $startCoordinates, 'startOffsetX' => $x1, 'startOffsetY' => $y1, 'endCoordinates' => $endCoordinates, 'endOffsetX' => $x2, 'endOffsetY' => $y2, ]; return $twoAnchor; }
php
{ "resource": "" }
q251579
CustomProperty.toXML
validation
function toXML() { $xml = new SimpleXMLElement("<?xml version=\"1.0\"?><property></property>"); $xml->addChild("key", $this->key); $xml->addChild("value", $this->value); return $xml; }
php
{ "resource": "" }
q251580
DataType.checkString
validation
public static function checkString($pValue) { if ($pValue instanceof RichText) { // TODO: Sanitize Rich-Text string (max. character count is 32,767) return $pValue; } // string must never be longer than 32,767 characters, truncate if necessary $pValue = StringHelper::substring($pValue, 0, 32767); // we require that newline is represented as "\n" in core, not as "\r\n" or "\r" $pValue = str_replace(["\r\n", "\r"], "\n", $pValue); return $pValue; }
php
{ "resource": "" }
q251581
DataType.checkErrorCode
validation
public static function checkErrorCode($pValue) { $pValue = (string) $pValue; if (!isset(self::$errorCodes[$pValue])) { $pValue = '#NULL!'; } return $pValue; }
php
{ "resource": "" }
q251582
CronjobIterator.validateColumns
validation
protected function validateColumns( $columns ) { $patterns = array( '((?P<minute>(?:\*|(?:(?:[0-9]|[1-5][0-9])(?:-(?:[0-9]|[1-5][0-9]))?)(?:,(?:[0-9]|[1-5][0-9])(?:-(?:[0-9]|[1-5][0-9]))?)*)(?:/(?:[1-9]|[1-5][0-9]))?)$)AD', '((?P<hour>(?:\*|(?:(?:[0-9]|1[0-9]|2[0-3])(?:-(?:[0-9]|1[0-9]|2[0-3]))?)(?:,(?:[0-9]|1[0-9]|2[0-3])(?:-(?:[0-9]|1[0-9]|2[0-3]))?)*)(?:/(?:[1-9]|1[0-9]|2[0-3]))?)$)AD', '((?P<dayOfMonth>(?:\*|(?:(?:[1-9]|[1-2][0-9]|3[0-1])(?:-(?:[1-9]|[1-2][0-9]|3[0-1]))?)(?:,(?:[1-9]|[1-2][0-9]|3[0-1])(?:-(?:[1-9]|[1-2][0-9]|3[0-1]))?)*)(?:/(?:[1-9]|[1-2][0-9]|3[0-1]))?)$)AD', '((?P<month>(?:\*|(?:(?:[1-9]|1[0-2])(?:-(?:[1-9]|1[1-2]))?)(?:,(?:[1-9]|1[1-2])(?:-(?:[1-9]|1[1-2]))?)*)(?:/(?:[1-9]|1[1-2]))?)$)AD', '((?P<dayOfWeek>(?:\*|(?:(?:[0-7])(?:-(?:[0-7]))?)(?:,(?:[0-7])(?:-(?:[0-7]))?)*)(?:/(?:[1-7]))?)$)AD', ); if ( count( $columns ) !== 5 ) { return false; } foreach( $columns as $key => $column ) { if ( preg_match( $patterns[$key], $column ) !== 1 ) { return (int)$key; } } return true; }
php
{ "resource": "" }
q251583
CronjobIterator.isValidDate
validation
protected function isValidDate( $year, $month, $day ) { // Some basic sanity checking if ( $month <= 0 || $month > 12 || $day <= 0 || $day > 31 ) { return false; } // Check for months with 30 days if ( ( $month == 4 || $month == 6 || $month == 9 || $month == 11 ) && ( $day == 31 ) ) { return false; } // Check for februaries if ( $month == 2 ) { // Februrary has a maximum of 29 dates (in a leap year) if ( $day > 29 ) { return false; } // Check if it is a leap year $leap = date( 'L', strtotime( $year . '-01-01' ) ); if ( $leap === '0' && $day > 28 ) { return false; } } return true; }
php
{ "resource": "" }
q251584
CronjobIterator.extractRange
validation
protected function extractRange( $definition, $min = null, $max=null ) { $resultSet = array(); if ( substr( $definition, 0, 1 ) === '*' ) { // We need ranges otherwise a full set can not be created if ( $min === null || $max === null ) { return false; } for( $i=$min; $i<=$max; ++$i ) { $resultSet[] = $i; } return $resultSet; } // Remove the stepping part if it is available if ( ( $position = strpos( $definition, '/' ) ) !== false ) { $definition = substr( $definition, 0, $position ); } // Split the definition into list elements. At least one elements needs // to be there $ranges = explode( ',', $definition ); foreach( $ranges as $range ) { // There might be a '-' sign which indicates a real range, split it accordingly. $entries = explode( '-', $range ); // If there is only one entry just add it to the result array if ( count( $entries ) === 1 ) { $resultSet[] = (int)$entries[0]; } // If a range is defined it needs to be calculated else { $high = (int)max( $entries ); $low = (int)min( $entries ); for( $i=$low; $i<=$high; ++$i ) { $resultSet[] = $i; } } } return $resultSet; }
php
{ "resource": "" }
q251585
CronjobIterator.extractStep
validation
protected function extractStep( $definition ) { if ( ( $position = strpos( $definition, '/' ) ) !== false ) { return (int)substr( $definition, $position + 1 ); } return false; }
php
{ "resource": "" }
q251586
CronjobIterator.applyStepping
validation
protected function applyStepping( $range, $step ) { if ( $step === false || $step === 1 ) { return $range; } foreach ( $range as $value => $tmp ) { if ( ( $value % $step ) !== 0 ) { unset( $range[$value] ); } } return array_values( $range ); }
php
{ "resource": "" }
q251587
CronjobIterator.getNextFutureTimestamp
validation
protected function getNextFutureTimestamp() { /* * To save time in pregeneration we use the array traversal functions * here to create iteratively accessed foreach loops on monthAndDays, * hours and minutes */ // These values are only used if we are inside the current year // Because they will not change significantly during the loop we are // just generating them once. if ( $this->yearOffset === 0 ) { $currentHour = (int)date( 'H', $this->getCurrentTime() ); $currentMinute = (int)date( 'i', $this->getCurrentTime() ); $currentDay = (int)date( 'd', $this->getCurrentTime() ); $currentMonth = (int)date( 'm', $this->getCurrentTime() ); } do { // Initialize all timetable values with their current value $minute = current( $this->minutes ); $hour = current( $this->hours ); $monthAndDay = current( $this->monthAndDays ); // Advance one step $minute = next( $this->minutes ); if ( $minute === false ) { // We reached the end of the minutes array. Therefore we need // to advance hours and reset minutes $minute = reset( $this->minutes ); $hour = next( $this->hours ); if ( $hour === false ) { // We reached the end of the hours array. Therefore we need // to advance monthAndDays and reset hours $hour = reset( $this->hours ); $monthAndDay = next( $this->monthAndDays ); if( $monthAndDay === false ) { // We reached the end of monthAndDays. Therefore we // need to generate new tables for the next year. $this->generateTimetable( $this->yearOffset + 1 ); // Use the first entry of every timetable array $minute = reset( $this->minutes ); $hour = reset( $this->hours ); $monthAndDay = reset( $this->monthAndDays ); } } } /* * We could use strtotime and just check against the timestamp here. * Unfortunately this would be slower by factor 3. Therefore this * manual checking routine is used */ // Only the current year is of interest everything else is in the // future anyway. if ( $this->yearOffset === 0 ) { if ( ( $month = (int)substr( $monthAndDay, 0, 2 ) ) === $currentMonth ) { if ( ( $day = (int)substr( $monthAndDay, 3, 2 ) ) < $currentDay ) { continue; } if ( $day === $currentDay ) { if ( $hour < $currentHour ) { continue; } if ( $hour === $currentHour ) { if ( $minute < $currentMinute ) { continue; } } } } } $nextElement = strtotime( sprintf( '%d-%s %02d:%02d:00', $this->year + $this->yearOffset, $monthAndDay, $hour, $minute ) ); // The next element has been found, therefore the loop can be // broken break; } while( true ); return $nextElement; }
php
{ "resource": "" }
q251588
CronjobIterator.current
validation
public function current() { $minute = current( $this->minutes ); $hour = current( $this->hours ); $monthAndDay = current( $this->monthAndDays ); $currentElement = strtotime( sprintf( '%d-%s %02d:%02d:00', $this->year + $this->yearOffset, $monthAndDay, $hour, $minute ) ); if ( $currentElement < $this->getCurrentTime() ) { $currentElement = $this->getNextFutureTimestamp(); } return $currentElement; }
php
{ "resource": "" }
q251589
CronjobIterator.rewind
validation
public function rewind() { /* * If we changed the years already we need to recalculate the data for * the first one */ if ( $this->yearOffset !== 0 ) { $this->generateTimetable( 0 ); } else { // Just reset the current array pointers if the year is correct reset( $this->minutes ); reset( $this->hours ); reset( $this->monthAndDays ); } }
php
{ "resource": "" }
q251590
Response.validateArgSet
validation
public function validateArgSet($set) { if (isset($set)) { foreach ($set as $arg) { if (!isset($this->{$arg})) { throw new \Exception('Response not valid: ' . $arg . ' has not been set!'); } } } }
php
{ "resource": "" }
q251591
Response.validate
validation
protected function validate() { $this->validateArgSet($this->args); if ($this->success) { $this->validateArgSet($this->successArgs); } if (!$this->success) { $this->validateArgSet($this->failureArgs); } }
php
{ "resource": "" }
q251592
Stk2kEventStreamAdapter.channel
validation
public function channel(string $channel_id) : EventChannelInterface { if (isset($this->channel_adapters[$channel_id])){ return $this->channel_adapters[$channel_id]; } $adapter = new Stk2kEventChannelAdapter( $this->eventstream->channel( $channel_id, function () { return new SimpleEventSource(); }, function () { return new WildCardEventEmitter(); } ) ); $this->channel_adapters[$channel_id] = $adapter; return $adapter; }
php
{ "resource": "" }
q251593
Throttle.getSourceByJob
validation
private function getSourceByJob($job) { $login = head(array_except($job->credentials, 'password')); return $login . app('request')->ip(); }
php
{ "resource": "" }
q251594
AbstractEventDispatcherPipe.fireEventOn
validation
private function fireEventOn($action, $payload) { $event = $this->getEventName(); $this->dispatcher->fire("auth.{$event}.{$action}", $payload); }
php
{ "resource": "" }
q251595
AbstractEventDispatcherPipe.getEventName
validation
protected function getEventName() { $chunks = explode('\\', get_class($this)); $name = $chunks[count($chunks) - 2]; return strtolower($name); }
php
{ "resource": "" }
q251596
CachingThrottler.incrementAttempts
validation
public function incrementAttempts() { $this->cache->add($this->key, 0, $this->getExpiry()); $this->cache->increment($this->key); }
php
{ "resource": "" }
q251597
CachingThrottler.lockOut
validation
public function lockOut() { $this->resetAttempts(); $this->cache->add($this->lockOutKey, $this->getDelay() + time(), $this->getExpiry()); }
php
{ "resource": "" }
q251598
ErrorHandler.highlightCode
validation
protected static function highlightCode(string $file, int $line, int $padding = 6) : array { if ( ! is_readable($file)) { return false; } $handle = fopen($file, 'r'); $lines = array(); $currentLine = 0; while ( ! feof($handle)) { $currentLine++; $temp = fgets($handle); if ($currentLine > $line + $padding) { break; // Exit loop after we have found what we were looking for } if ($currentLine >= ($line - $padding) && $currentLine <= ($line + $padding)) { $lines[] = array ( 'number' => str_pad($currentLine, 4, ' ', STR_PAD_LEFT), 'highlighted' => ($currentLine === $line), 'code' => ErrorHandler::highlightString($temp), ); } } fclose($handle); return $lines; }
php
{ "resource": "" }
q251599
ErrorHandler.error
validation
public static function error(int $code, string $message, string $file, int $line) : bool { // If isset error_reporting and $code then throw new error exception if ((error_reporting() & $code) !== 0) { /** * Dont thow NOTICE exception for PRODUCTION Environment. Just write to log. */ if (DEVELOPMENT == false && $code == 8) { // Get exception info $error['code'] = $code; $error['message'] = $message; $error['file'] = $file; $error['line'] = $line; $error['type'] = 'ErrorException: '; $codes = array ( E_USER_NOTICE => 'Notice', ); $error['type'] .= in_array($error['code'], array_keys($codes)) ? $codes[$error['code']] : 'Unknown Error'; // Write to log ErrorHandler::writeLogs("{$error['type']}: {$error['message']} in {$error['file']} at line {$error['line']}"); } else { throw new \ErrorException($message, $code, 0, $file, $line); } } // Don't execute PHP internal error handler return true; }
php
{ "resource": "" }