sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public function getParentDirectories()
{
if ($this->isCurrentDirectoryBase()) {
return [];
}
$currentDir = $this->currentDir;
$dirs = [];
do {
$dir = dirname($currentDir);
$dirs[] = $this->getPathRelativeToBaseDir($dir)
?: ... | Returns parent directories of current directory.
@return array | entailment |
public function handle($request, Closure $next, $guard = null)
{
$locale = $this->determinerManager->determineLocale($request);
$this->app->setLocale($locale);
return $next($request);
} | Handle an incoming request.
@param \Illuminate\Http\Request $request
@param \Closure $next
@param string|null $guard
@return mixed | entailment |
public function add($item)
{
// init array
if (!is_array($this->_get($this->getAttributeName()))) {
$this->_set($this->getAttributeName(), []);
}
// current array
$currentArray = $this->_get($this->getAttributeName());
array_push($currentArray, $item);
... | Default method adding item to array
@uses AbstractStructArrayBase::getAttributeName()
@uses AbstractStructArrayBase::__toString()
@uses AbstractStructArrayBase::_set()
@uses AbstractStructArrayBase::_get()
@uses AbstractStructArrayBase::setInternArray()
@uses AbstractStructArrayBase::setInternArrayIsArray()
@uses Abstr... | entailment |
public function offsetSet($offset, $value)
{
$this->internArray[$offset] = $value;
return $this->_set($this->getAttributeName(), $this->internArray);
} | Method setting value at offset
@param mixed $offset
@param mixed $value
@return AbstractStructArrayBase | entailment |
public function offsetUnset($offset)
{
if ($this->offsetExists($offset)) {
unset($this->internArray[$offset]);
$this->_set($this->getAttributeName(), $this->internArray);
}
return $this;
} | Method unsetting value at offset
@param mixed $offset
@return AbstractStructArrayBase | entailment |
public function initInternArray($array = [], $internCall = false)
{
if (is_array($array) && count($array) > 0) {
$this
->setInternArray($array)
->setInternArrayOffset(0)
->setInternArrayIsArray(true);
} elseif (!$internCall && property_exis... | Method initiating internArray
@uses AbstractStructArrayBase::setInternArray()
@uses AbstractStructArrayBase::setInternArrayOffset()
@uses AbstractStructArrayBase::setInternArrayIsArray()
@uses AbstractStructArrayBase::getAttributeName()
@uses AbstractStructArrayBase::initInternArray()
@uses AbstractStructArrayBase::__t... | entailment |
public function handle()
{
$env = new Env(base_path('.env'));
$key = strtoupper($this->argument('key'));
$result = $env->delete($key)->get($key);
if ($result !== '' && ! is_null($result)) {
$env->rollback();
return $this->comment("No value was found for \"$... | Execute the console command.
@return void | entailment |
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$root = $treeBuilder->root('happyr_linkedin');
$root->children()
->scalarNode('http_client')->defaultValue('httplug.client')->info('A service id for a Httplug adapter')->end()
->scalarNode('ht... | {@inheritdoc} | entailment |
public function register()
{
$this->commands([
Commands\SetEnv::class,
Commands\GetEnv::class,
Commands\DeleteEnv::class,
Commands\ListEnv::class,
]);
} | Register the application services.
@return void | entailment |
public function hasPermissionTo($permission): bool
{
if (is_string($permission)) {
$permission = PermissionProxy::findByName($permission, $this->getDefaultGuardName());
}
if (! $this->getGuardNames()->contains($permission->guard_name)) {
throw GuardDoesNotMatch::crea... | Determine if the user may perform the given permission.
@param string|Permission $permission
@return bool
@throws \Konekt\Acl\Exceptions\GuardDoesNotMatch | entailment |
public function getpdf($html)
{
// test if dompdf config exists in symfony app folder
$testFilePath = "/../../../../../../app/dompdf_config.inc.php";
if (file_exists(dirname(__FILE__).$testFilePath)) {
require_once(dirname(__FILE__).$testFilePath);
}
else {
require_once dirname(__FILE__).'/../DomPDF/do... | Render a pdf document
@param string $html The html to be rendered
@param string $docname The name of the document to be served | entailment |
public function determineLocale(Request $request)
{
return $this->hostMapping->flip()->get($request->getHost(), $this->fallback);
} | Determine the locale from the current host.
@param \Illuminate\Http\Request $request
@return string | entailment |
public function contactsAction($objectId, $page = 1)
{
$manuallyRemoved = 0;
$listFilters = ['manually_removed' => $manuallyRemoved];
if ('POST' === $this->request->getMethod() && $this->request->request->has('includeEvents')) {
$filters = [
'includeEvents' =>... | @param $objectId
@param int $page
@return mixed|\Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response | entailment |
public function initSoapClient(array $options)
{
$wsdlOptions = [];
$defaultWsdlOptions = static::getDefaultWsdlOptions();
foreach ($defaultWsdlOptions as $optionName => $optionValue) {
if (array_key_exists($optionName, $options) && !is_null($options[$optionName])) {
... | Method initiating SoapClient
@uses ApiClassMap::classMap()
@uses AbstractSoapClientBase::getDefaultWsdlOptions()
@uses AbstractSoapClientBase::getSoapClientClassName()
@uses AbstractSoapClientBase::setSoapClient()
@uses AbstractSoapClientBase::OPTION_PREFIX
@param array $options WSDL options
@return void | entailment |
protected static function canInstantiateSoapClientWithOptions($wsdlOptions)
{
return (
array_key_exists(str_replace(self::OPTION_PREFIX, '', self::WSDL_URL), $wsdlOptions) ||
(
array_key_exists(str_replace(self::OPTION_PREFIX, '', self::WSDL_URI), $wsdlOptions) &&
... | Checks if the provided options are sufficient to instantiate a SoapClient:
- WSDL-mode : only the WSDL is required
- non-WSDL-mode : URI and LOCATION are required, WSDL url can be empty then
@uses AbstractSoapClientBase::OPTION_PREFIX
@param $wsdlOptions
@return bool | entailment |
public function getSoapClientClassName($soapClientClassName = null)
{
$className = self::DEFAULT_SOAP_CLIENT_CLASS;
if (!empty($soapClientClassName) && is_subclass_of($soapClientClassName, '\SoapClient')) {
$className = $soapClientClassName;
}
return $className;
} | Returns the SoapClient class name to use to create the instance of the SoapClient.
The SoapClient class is determined based on the package name.
If a class is named as {Api}SoapClient, then this is the class that will be used.
Be sure that this class inherits from the native PHP SoapClient class and this class has been... | entailment |
public static function getDefaultWsdlOptions()
{
return [
self::WSDL_AUTHENTICATION => null,
self::WSDL_CACHE_WSDL => WSDL_CACHE_NONE,
self::WSDL_CLASSMAP => null,
self::WSDL_COMPRESSION => null,
self::WSDL_CONNECTION_TIMEOUT => null,
s... | Method returning all default options values
@uses AbstractSoapClientBase::WSDL_AUTHENTICATION
@uses AbstractSoapClientBase::WSDL_CACHE_WSDL
@uses AbstractSoapClientBase::WSDL_CLASSMAP
@uses AbstractSoapClientBase::WSDL_COMPRESSION
@uses AbstractSoapClientBase::WSDL_CONNECTION_TIMEOUT
@uses AbstractSoapClientBase::WSDL_... | entailment |
public function setLocation($location)
{
if ($this->getSoapClient() instanceof \SoapClient) {
$this->getSoapClient()->__setLocation($location);
}
return $this;
} | Allows to set the SoapClient location to call
@uses AbstractSoapClientBase::getSoapClient()
@uses SoapClient::__setLocation()
@param string $location
@return AbstractSoapClientBase | entailment |
public static function convertStringHeadersToArray($headers)
{
$lines = explode("\r\n", $headers);
$headers = [];
foreach ($lines as $line) {
if (strpos($line, ':')) {
$headerParts = explode(':', $line);
$headers[$headerParts[0]] = trim(implode(':'... | Returns an associative array between the headers name and their respective values
@param string $headers
@return string[] | entailment |
public function setSoapHeader($nameSpace, $name, $data, $mustUnderstand = false, $actor = null)
{
if ($this->getSoapClient()) {
$defaultHeaders = (isset($this->getSoapClient()->__default_headers) && is_array($this->getSoapClient()->__default_headers)) ? $this->getSoapClient()->__default_headers ... | Sets a SoapHeader to send
For more information, please read the online documentation on {@link http://www.php.net/manual/en/class.soapheader.php}
@uses AbstractSoapClientBase::getSoapClient()
@uses SoapClient::__setSoapheaders()
@param string $nameSpace SoapHeader namespace
@param string $name SoapHeader name
@param mi... | entailment |
public function setHttpHeader($headerName, $headerValue)
{
$state = false;
if ($this->getSoapClient() && !empty($headerName)) {
$streamContext = $this->getStreamContext();
if ($streamContext === null) {
$options = [];
$options['http'] = [];
... | Sets the SoapClient Stream context HTTP Header name according to its value
If a context already exists, it tries to modify it
It the context does not exist, it then creates it with the header name and its value
@uses AbstractSoapClientBase::getSoapClient()
@param string $headerName
@param mixed $headerValue
@return boo... | entailment |
public function getStreamContext()
{
return ($this->getSoapClient() && isset($this->getSoapClient()->_stream_context) && is_resource($this->getSoapClient()->_stream_context)) ? $this->getSoapClient()->_stream_context : null;
} | Returns current \SoapClient::_stream_context resource or null
@return resource|null | entailment |
public function getStreamContextOptions()
{
$options = [];
$context = $this->getStreamContext();
if ($context !== null) {
$options = stream_context_get_options($context);
}
return $options;
} | Returns current \SoapClient::_stream_context resource options or empty array
@return array | entailment |
public function getLastErrorForMethod($methodName)
{
return array_key_exists($methodName, $this->lastError) ? $this->lastError[$methodName] : null;
} | Method getting the last error for a certain method
@param string $methodName method name to get error from
@return \SoapFault|null | entailment |
public function handle()
{
$env = new Env(base_path('.env'));
$key = strtoupper($this->argument('key'));
$value = (string) $this->argument('value');
$linebreak = (bool) $this->option('line-break');
$result = $env->set($key, $value, $linebreak)->get($key);
if ($resul... | Execute the console command.
@return void | entailment |
public function handle()
{
$env = new Env(base_path('.env'));
$name = (string) $this->option('name');
try {
$env->copy(
base_path($name, Env::COPY_FOR_DISTRIBUTION)
);
return $this->comment("Successfully created the file [$name]");
... | Execute the console command.
@return void | entailment |
public static function getFormatedXml($string, $asDomDocument = false)
{
if (!is_null($string)) {
$domDocument = self::getDOMDocument($string);
return $asDomDocument ? $domDocument : $domDocument->saveXML();
}
return null;
} | Returns a XML string content as a DOMDocument or as a formated XML string
@throws \InvalidArgumentException
@param string $string
@param bool $asDomDocument
@return \DOMDocument|string|null | entailment |
public function handle()
{
$env = new Env(base_path('.env'));
$data = [];
foreach ($env->all() as $key => $value) {
$data[] = [$key, $value];
}
return $this->table(['Key', 'Value'], $data);
} | Execute the console command.
@return void | entailment |
public function browse($base = '0', $browseflag = 'BrowseDirectChildren', $start = 0, $count = 0)
{
libxml_use_internal_errors(true); //is this still needed?
$args = array(
'ObjectID'=>$base,
'BrowseFlag'=>$browseflag,
'Filter'=>'',
'StartingIndex'=>$s... | BrowseDirectChildren or BrowseMetadata | entailment |
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('ijanki_ftp');
$rootNode = method_exists($treeBuilder, 'getRootNode') ? $treeBuilder->getRootNode() : $treeBuilder->root('ijanki_ftp');
// Here you should define the parameters that are allowed to
// configure y... | {@inheritDoc} | entailment |
public function putContents($file_name, $data, $mode = FTP_ASCII)
{
if (!is_resource($this->resource)) {
throw new FtpException("Not connected to FTP server. Call connect() or ssl_connect() first.");
}
$temp = tmpfile();
fwrite($temp, $data);
fseek($temp, 0);
... | Put a string in remote $file_name | entailment |
public function connectUrl($url)
{
if(!preg_match('!^ftp(?<ssl>s?)://(?<user>[^:]+):(?<pass>[^@]+)@(?<host>[^:/]+)(?:[:](?<port>\d+))?(?<path>.*)$!i', $url, $match)) {
throw new FtpException('Url must be in format: ftp[s]://username:password@hostname[:port]/[path]');
}
// defaul... | Interpret connection info from url string | entailment |
public function generateHash(array $data)
{
if ($this->getSecretKey()) {
//begin HASH calculation
ksort($data);
$hashString = "";
foreach ($data as $key => $val) {
$hashString .= strlen($val) . $val;
}
return hash_hmac("... | HMAC_MD5 signature applied on all parameters from the request.
Source string for HMAC_MD5 will be calculated by adding the length
of each field value at the beginning of field value. A common key
shared between PayU and the merchant is used for the signature.
Find more details on how is HASH generated https://secure.pa... | entailment |
public function reset()
{
$this->values[self::PROTOCOL_VERSION] = null;
$this->values[self::SOURCE_ID] = null;
$this->values[self::DESTINATION_ID] = null;
$this->values[self::NNAMESPACE] = null;
$this->values[self::PAYLOAD_TYPE] = null;
$this->values[self::PAYLOAD_UTF... | Clears message values and sets default ones
@return null | entailment |
public function getChannels()
{
$response = $this->channel->addMessage('query/apps', false);
$xml = simplexml_load_string($response);
$channels = array();
foreach($xml->app as $app){
$app_id = $app->attributes()->id;
$channels[(string)$app_id] = array(
... | to not confuse with communication channels, consider renaming to getApplications | entailment |
public static function indentLines($lines, $indent = ' ')
{
$lineSeparator = "\n";
$buffer = '';
$line = strtok($lines, $lineSeparator);
while ($line) {
$buffer .= $indent . $line . $lineSeparator;
$line = strtok($lineSeparator);
}
... | indentLines()
this will add a line-separator at the end of the last line because if it was
empty it is not any longer and deserves one.
@param string $lines
@param string $indent (optional)
@return string | entailment |
public static function startTag($name, $attributes, $emptyTag = false)
{
$buffer = '<' . $name;
$buffer .= static::attributes($attributes);
$buffer .= $emptyTag ? '/>' : '>';
return $buffer;
} | @param string $name
@param array|Traversable $attributes attributeName => attributeValue string pairs
@param bool $emptyTag create an empty element tag (commonly known as short tags)
@return string | entailment |
public static function attributes($attributes)
{
$buffer = '';
foreach ($attributes as $name => $value) {
$buffer .= ' ' . $name . '="' . static::attributeValue($value) . '"';
}
return $buffer;
} | @param array|Traversable $attributes attributeName => attributeValue string pairs
@return string | entailment |
public static function attributeValue($value)
{
$buffer = $value;
// REC-xml/#AVNormalize - preserve
// REC-xml/#sec-line-ends - preserve
$buffer = preg_replace_callback('~\r\n|\r(?!\n)|\t~', array('self', 'numericEntitiesSingleByte'), $buffer);
return htmlspecialchars($buf... | @param string $value
@see XMLBuild::numericEntitiesSingleByte
@return string | entailment |
public static function wrapTag($name, $attributes, $innerXML)
{
if (!strlen($innerXML)) {
return XMLBuild::startTag($name, $attributes, true);
}
return
XMLBuild::startTag($name, $attributes)
. "\n"
. XMLBuild::indentLines($innerXML)
... | @param string $name
@param array|Traversable $attributes attributeName => attributeValue string pairs
@param string $innerXML
@return string | entailment |
public static function readerNode(XMLReader $reader)
{
switch ($reader->nodeType) {
case XMLREADER::NONE:
return '%(0)%';
case XMLReader::ELEMENT:
return XMLBuild::startTag($reader->name, new XMLAttributeIterator($reader));
default:
... | @param XMLReader $reader
@return string | entailment |
private static function numericEntitiesSingleByte($matches)
{
$buffer = str_split($matches[0]);
foreach ($buffer as &$char) {
$char = sprintf('&#%d;', ord($char));
}
return implode('', $buffer);
} | @param array $matches
@return string
@see attributeValue() | entailment |
public function moveToNextByNodeType($nodeType)
{
if (null === self::valid()) {
self::rewind();
} elseif (self::valid()) {
self::next();
}
while (self::valid()) {
if ($this->reader->nodeType === $nodeType) {
break;
}
... | @param int $nodeType
@return bool|\XMLReaderNode | entailment |
private function moveReaderToCurrent()
{
if (
($this->reader->nodeType === XMLReader::NONE)
or ($this->reader->nodeType !== XMLReader::ELEMENT)
or ($this->localName && $this->localName !== $this->reader->localName)
) {
self::next();
}
} | move cursor to the next element but only if it's not yet there | entailment |
public function isEndElementOfEmptyElement()
{
return
$this->reader->nodeType === XMLReader::END_ELEMENT
&& $this->lastDepth === $this->reader->depth
&& $this->lastNode instanceof DOMElement
&& !$this->reader->isEmptyElement;
} | The element by marked by type XMLReader::END_ELEMENT
is empty (has no children) but not self-closing.
@return bool | entailment |
public function getSimpleXMLElement()
{
if (null === $this->simpleXML) {
if ($this->reader->nodeType !== XMLReader::ELEMENT) {
return null;
}
$node = $this->expand();
$this->simpleXML = simplexml_import_dom($node);
}
... | SimpleXMLElement for XMLReader::ELEMENT
@return SimpleXMLElement|null in case the current node can not be converted into a SimpleXMLElement
@since 0.1.4 | entailment |
public function getAttribute($name, $default = null)
{
$value = $this->reader->getAttribute($name);
return null !== $value ? $value : $default;
} | @param string $name attribute name
@param string $default (optional) if the attribute with $name does not exists, the value to return
@return null|string value of the attribute, if attribute with $name does not exists null (by $default) | entailment |
public function getChildElements($name = null, $descendantAxis = false)
{
return new XMLChildElementIterator($this->reader, $name, $descendantAxis);
} | @param string $name (optional) element name, null or '*' stand for each element
@param bool $descendantAxis descend into children of children and so on?
@return XMLChildElementIterator|XMLReaderNode[] | entailment |
public function readOuterXml()
{
// Compatibility libxml 20620 (2.6.20) or later - LIBXML_VERSION / LIBXML_DOTTED_VERSION
if (method_exists($this->reader, 'readOuterXml')) {
return $this->reader->readOuterXml();
}
if (0 === $this->reader->nodeType) {
return ... | Decorated method
@throws BadMethodCallException in case XMLReader can not expand the node
@return string | entailment |
public function expand(DOMNode $basenode = null)
{
if (null === $basenode) {
$basenode = new DomDocument();
}
if ($basenode instanceof DOMDocument) {
$doc = $basenode;
} else {
$doc = $basenode->ownerDocument;
}
if (false === $nod... | XMLReader expand node and import it into a DOMNode with a DOMDocument
This is for example useful for DOMDocument::saveXML() @see readOuterXml
or getting a SimpleXMLElement out of it @see getSimpleXMLElement
@throws BadMethodCallException
@param DOMNode $basenode
@return DOMNode | entailment |
public function readString()
{
// Compatibility libxml 20620 (2.6.20) or later - LIBXML_VERSION / LIBXML_DOTTED_VERSION
if (method_exists($this->reader, 'readString')) {
return $this->reader->readString();
}
if (0 === $this->reader->nodeType) {
return '';
... | Decorated method
@throws BadMethodCallException
@return string | entailment |
public function getNodeTypeName($nodeType = null)
{
$strings = array(
XMLReader::NONE => 'NONE',
XMLReader::ELEMENT => 'ELEMENT',
XMLReader::ATTRIBUTE => 'ATTRIBUTE',
XMLREADER::TEXT => 'TEXT',
... | Return node-type as human readable string (constant name)
@param null $nodeType
@return string | entailment |
public static function dump(XMLReader $reader, $return = FALSE)
{
$node = new self($reader);
$nodeType = $reader->nodeType;
$nodeName = $node->getNodeTypeName();
$extra = '';
if ($reader->nodeType === XMLReader::ELEMENT) {
$extra = '<' . $reader->name . '> ';
... | debug utility method
@param XMLReader $reader
@param bool $return (optional) prints by default but can return string
@return string|null | entailment |
private function ensureCurrentElementState()
{
if ($this->reader->nodeType !== XMLReader::ELEMENT) {
$this->moveToNextElementByName($this->name);
} elseif ($this->name && $this->name !== $this->reader->name) {
$this->moveToNextElementByName($this->name);
}
} | take care the underlying XMLReader is at an element with a fitting name (if $this is looking for a name) | entailment |
public function fopen($filename, $mode, $use_include_path = null, $context = null) {
if ($mode !== self::MODE_READ_BINARY) {
$message = sprintf(
"unsupported mode '%s', only '%s' is supported for buffered file read", $mode, self::MODE_READ_BINARY
);
trigger_e... | @param $filename
@param $mode
@param null $use_include_path
@param null $context
@return bool | entailment |
public function append($count)
{
$bufferLen = strlen($this->buffer);
if ($bufferLen >= $count + $this->maxAhead) {
return $bufferLen;
}
($ahead = $this->readAhead)
&& ($delta = $bufferLen - $ahead) < 0
&& $count -= $delta;
$read = fread(... | appends up to $count bytes to the buffer up to
the read-ahead limit
@param $count
@return int|bool length of buffer or FALSE on error | entailment |
public function shift($bytes)
{
$bufferLen = strlen($this->buffer);
if ($bytes === $bufferLen) {
$return = $this->buffer;
$this->buffer = '';
} else {
$return = substr($this->buffer, 0, $bytes);
$this->buffer = substr($this->buffer... | shift bytes from buffer
@param $bytes - up to buffer-length bytes
@return string | entailment |
public function getReaderForFile($filename, $mode, $use_include_path, $context)
{
$readers = $this->readers;
if (!isset($readers[$filename])) {
$reader = new BufferedFileRead();
$result = $reader->fopen($filename, $mode, $use_include_path, $context);
return $this... | @param $filename
@param $mode
@param $use_include_path
@param $context
@return BufferedFileRead or null on error | entailment |
public static function closeBuffer($path)
{
if (!self::$readers) {
return false;
}
$path = new XMLSequenceStreamPath($path);
$file = $path->getFile();
return self::$readers->removeReaderForFile($file);
} | @param string $path filename of the buffer to close, complete with wrapper prefix
@return bool | entailment |
public static function notAtEndOfSequence($path)
{
if (!self::$readers) {
return true;
}
try {
$path = new XMLSequenceStreamPath($path);
} catch (UnexpectedValueException $e) {
return true;
}
$file = $path->getFile();
ret... | @param $path
@return bool | entailment |
public function stream_open($path, $mode, $options, &$opened_path)
{
# fputs(STDOUT, sprintf('<open: %s - raise errors: %d - use path: %d >', var_export($path, 1), $options & STREAM_REPORT_ERRORS, $options & STREAM_USE_PATH));
$path = new XMLSequenceStreamPath($path);
$file = $path-... | @param string $path
@param string $mode
@param int $options
@param string $opened_path
@return bool | entailment |
public function getControlURL($description_url, $service = 'AVTransport')
{
$description = $this->getDescription($description_url);
switch($service)
{
case 'AVTransport':
$serviceType = 'urn:schemas-upnp-org:service:AVTransport:1';
break;
default:
$serviceType = 'urn:schemas-upnp-org:service:A... | this should be moved to the upnp and renderer model | entailment |
public function daysInMonth($year, $month)
{
if ($year <= 0) {
throw new InvalidArgumentException('Year ' . $year . ' is invalid for this calendar');
} elseif ($month < 1 || $month > 13) {
throw new InvalidArgumentException('Month ' . $month . ' is invalid for this calendar')... | Determine the number of days in a specified month, allowing for leap years, etc.
@param int $year
@param int $month
@return int | entailment |
public function jdToYmd($julian_day)
{
$depoch = $julian_day - 2121446; // 1 Farvardīn 475
$cycle = (int) floor($depoch / 1029983);
$cyear = $this->mod($depoch, 1029983);
if ($cyear == 1029982) {
$ycycle = 2820;
} else {
$aux1 = (int) ($cyear / 366... | Convert a Julian day number into a year/month/day.
@param int $julian_day
@return int[] | entailment |
public function ymdToJd($year, $month, $day)
{
if ($month < 1 || $month > $this->monthsInYear()) {
throw new InvalidArgumentException('Month ' . $month . ' is invalid for this calendar');
}
$epbase = $year - (($year >= 0) ? 474 : 473);
$epyear = 474 + $this->mod($epbase,... | Convert a year/month/day to a Julian day number.
@param int $year
@param int $month
@param int $day
@return int | entailment |
public function mod($dividend, $divisor)
{
if ($divisor === 0) {
return 0;
}
$modulus = $dividend % $divisor;
if ($modulus < 0) {
$modulus += $divisor;
}
return $modulus;
} | The PHP modulus function returns a negative modulus for a negative dividend.
This algorithm requires a "traditional" modulus function where the modulus is
always positive.
@param int $dividend
@param int $divisor
@return int | entailment |
public function save(Identifiable $data)
{
Assertion::isInstanceOf($data, $this->class);
$serializedReadModel = $this->serializer->serialize($data);
$params = [
'index' => $this->index,
'type' => $serializedReadModel['class'],
'id' => $data->ge... | {@inheritDoc} | entailment |
public function find($id)
{
$params = [
'index' => $this->index,
'type' => $this->class,
'id' => $id,
];
try {
$result = $this->client->get($params);
} catch (Missing404Exception $e) {
return null;
}
re... | {@inheritDoc} | entailment |
public function remove($id)
{
try {
$this->client->delete([
'id' => $id,
'index' => $this->index,
'type' => $this->class,
'refresh' => true,
]);
} catch (Missing404Exception $e) { // It was already dele... | {@inheritDoc} | entailment |
public function createIndex(): bool
{
$class = $this->class;
$indexParams = [
'index' => $this->index,
];
if (count($this->notAnalyzedFields)) {
$indexParams['body'] = [
'mappings' => [
$class => [
... | Creates the index for this repository's ReadModel.
@return boolean True, if the index was successfully created | entailment |
public function deleteIndex(): bool
{
$indexParams = [
'index' => $this->index,
'timeout' => '5s',
];
$this->client->indices()->delete($indexParams);
$response = $this->client->cluster()->health([
'index' => $this->index,
... | Deletes the index for this repository's ReadModel.
@return True, if the index was successfully deleted | entailment |
public function ymdToJd($year, $month, $day)
{
if ($month < 1 || $month > $this->monthsInYear()) {
throw new InvalidArgumentException('Month ' . $month . ' is invalid for this calendar');
}
if ($year < 0) {
// 1 BCE is 0, 2 BCE is -1, etc.
++$year;
... | Convert a year/month/day into a Julian day number
@param int $year
@param int $month
@param int $day
@return int | entailment |
public function easterDays($year)
{
// The “golden” number
$golden = $year % 19 + 1;
// The “dominical” number (finding a Sunday)
$dom = ($year + (int) ($year / 4) - (int) ($year / 100) + (int) ($year / 400)) % 7;
if ($dom < 0) {
$dom += 7;
}
// ... | Get the number of days after March 21 that easter falls, for a given year.
Uses the algorithm found in PHP’s ext/calendar/easter.c
@param int $year
@return int | entailment |
public static function create()
{
self::$french_calendar = new FrenchCalendar();
self::$gregorian_calendar = new GregorianCalendar();
self::$jewish_calendar = new JewishCalendar(array(
JewishCalendar::EMULATE_BUG_54254 => self::shouldEmulateBug54254(),
));
s... | Create the necessary shims to emulate the ext/calendar package.
@return void | entailment |
public static function calDaysInMonth($calendar_id, $month, $year)
{
switch ($calendar_id) {
case CAL_FRENCH:
return self::calDaysInMonthFrench($year, $month);
case CAL_GREGORIAN:
return self::calDaysInMonthCalendar(self::$gregorian_calendar, $year, $... | Return the number of days in a month for a given year and calendar.
Shim implementation of cal_days_in_month()
@link https://php.net/cal_days_in_month
@link https://bugs.php.net/bug.php?id=67976
@param int $calendar_id
@param int $month
@param int $year
@return int|bool The number of days in the specified month, or... | entailment |
private static function calDaysInMonthCalendar(CalendarInterface $calendar, $year, $month)
{
try {
return $calendar->daysInMonth($year, $month);
} catch (InvalidArgumentException $ex) {
$error_msg = PHP_VERSION_ID < 70200 ? 'invalid date.' : 'invalid date';
retur... | Calculate the number of days in a month in a specified (Gregorian or Julian) calendar.
@param CalendarInterface $calendar
@param int $year
@param int $month
@return int|bool | entailment |
private static function calDaysInMonthFrench($year, $month)
{
if ($month == 13 && $year == 14 && self::shouldEmulateBug67976()) {
return -2380948;
} elseif ($year > 14) {
$error_msg = PHP_VERSION_ID < 70200 ? 'invalid date.' : 'invalid date';
return trigger_error... | Calculate the number of days in a month in the French calendar.
Mimic PHP’s validation of the parameters
@param int $year
@param int $month
@return int|bool | entailment |
public static function calFromJd($julian_day, $calendar_id)
{
switch ($calendar_id) {
case CAL_FRENCH:
return self::calFromJdCalendar($julian_day, self::jdToFrench($julian_day), self::$MONTH_NAMES_FRENCH, self::$MONTH_NAMES_FRENCH);
case CAL_GREGORIAN:
... | Converts from Julian Day Count to a supported calendar.
Shim implementation of cal_from_jd()
@link https://php.net/cal_from_jd
@param int $julian_day Julian Day number
@param int $calendar_id Calendar constant
@return array|bool | entailment |
private static function calFromJdCalendar($julian_day, $mdy, $months, $months_short)
{
list($month, $day, $year) = explode('/', $mdy);
return array(
'date' => $month . '/' . $day . '/' . $year,
'month' => (int) $month,
'day' => (int) $d... | Convert a Julian day number to a calendar and provide details.
@param int $julian_day
@param string $mdy
@param string[] $months
@param string[] $months_short
@return array | entailment |
public static function calInfo($calendar_id)
{
switch ($calendar_id) {
case CAL_FRENCH:
return self::calInfoCalendar(self::$MONTH_NAMES_FRENCH, self::$MONTH_NAMES_FRENCH, 30, 'French', 'CAL_FRENCH');
case CAL_GREGORIAN:
return self::calInfoCalendar(se... | Returns information about a particular calendar.
Shim implementation of cal_info()
@link https://php.net/cal_info
@param int $calendar_id
@return array|bool | entailment |
private static function calInfoCalendar($month_names, $month_names_short, $max_days_in_month, $calendar_name, $calendar_symbol)
{
return array(
'months' => array_slice($month_names, 1, null, true),
'abbrevmonths' => array_slice($month_names_short, 1, null, true),
... | Returns information about the French calendar.
@param string[] $month_names
@param string[] $month_names_short
@param int $max_days_in_month
@param string $calendar_name
@param string $calendar_symbol
@return array | entailment |
public static function calToJd($calendar_id, $month, $day, $year)
{
switch ($calendar_id) {
case CAL_FRENCH:
return self::frenchToJd($month, $day, $year);
case CAL_GREGORIAN:
return self::gregorianToJd($month, $day, $year);
case CAL_JEWIS... | Converts from a supported calendar to Julian Day Count
Shim implementation of cal_to_jd()
@link https://php.net/cal_to_jd
@param int $calendar_id
@param int $month
@param int $day
@param int $year
@return int|bool | entailment |
public static function easterDate($year)
{
if ($year < 1970 || $year > 2037) {
return trigger_error('This function is only valid for years between 1970 and 2037 inclusive', E_USER_WARNING);
}
$days = self::$gregorian_calendar->easterDays($year);
// Calculate time-zone o... | Get Unix timestamp for midnight on Easter of a given year.
Shim implementation of easter_date()
@link https://php.net/easter_date
@param int $year
@return int|bool | entailment |
public static function easterDays($year, $method)
{
if ($method == CAL_EASTER_ALWAYS_JULIAN ||
$method == CAL_EASTER_ROMAN && $year <= 1582 ||
$year <= 1752 && $method != CAL_EASTER_ROMAN && $method != CAL_EASTER_ALWAYS_GREGORIAN
) {
return self::$julian_calendar-... | Get number of days after March 21 on which Easter falls for a given year.
Shim implementation of easter_days()
@link https://php.net/easter_days
@param int $year
@param int $method Use the Julian or Gregorian calendar
@return int | entailment |
public static function frenchToJd($month, $day, $year)
{
if ($year <= 0) {
return 0;
} else {
return self::$french_calendar->ymdToJd($year, $month, $day);
}
} | Converts a date from the French Republican Calendar to a Julian Day Count.
Shim implementation of FrenchToJD()
@link https://php.net/FrenchToJD
@param int $month
@param int $day
@param int $year
@return int | entailment |
public static function gregorianToJd($month, $day, $year)
{
if ($year == 0) {
return 0;
} else {
return self::$gregorian_calendar->ymdToJd($year, $month, $day);
}
} | Converts a Gregorian date to Julian Day Count.
Shim implementation of GregorianToJD()
@link https://php.net/GregorianToJD
@param int $month
@param int $day
@param int $year
@return int | entailment |
public static function jdDayOfWeek($julian_day, $mode)
{
$day_of_week = ($julian_day + 1) % 7;
if ($day_of_week < 0) {
$day_of_week += 7;
}
switch ($mode) {
case 1: // 1, not CAL_DOW_LONG - see bug 67960
return self::$DAY_NAMES[$day_of_week];
... | Returns the day of the week.
Shim implementation of JDDayOfWeek()
@link https://php.net/JDDayOfWeek
@link https://bugs.php.net/bug.php?id=67960
@param int $julian_day
@param int $mode
@return int|string | entailment |
public static function jdMonthName($julian_day, $mode)
{
switch ($mode) {
case CAL_MONTH_GREGORIAN_LONG:
return self::jdMonthNameCalendar(self::$gregorian_calendar, $julian_day, self::$MONTH_NAMES);
case CAL_MONTH_JULIAN_LONG:
return self::jdMonthName... | Returns a month name.
Shim implementation of JDMonthName()
@link https://php.net/JDMonthName
@param int $julian_day
@param int $mode
@return string | entailment |
private static function jdMonthNameCalendar(CalendarInterface $calendar, $julian_day, $months)
{
list(, $month) = $calendar->jdToYmd($julian_day);
return $months[$month];
} | Calculate the month-name for a given julian day, in a given calendar,
with given set of month names.
@param CalendarInterface $calendar
@param int $julian_day
@param string[] $months
@return string | entailment |
private static function jdMonthNameJewishMonths($julian_day)
{
list(, , $year) = explode('/', self::jdToCalendar(self::$jewish_calendar, $julian_day, 347998, 324542846));
if (self::$jewish_calendar->isLeapYear($year)) {
return self::shouldEmulateBug54254() ? self::$MONTH_NAMES_JEWISH_54... | Determine which month names to use for the Jewish calendar.
@param int $julian_day
@return string[] | entailment |
private static function jdToCalendar(CalendarInterface $calendar, $julian_day, $min_jd, $max_jd)
{
if ($julian_day >= $min_jd && $julian_day <= $max_jd) {
list($year, $month, $day) = $calendar->jdToYmd($julian_day);
return $month . '/' . $day . '/' . $year;
} else {
... | Convert a Julian day in a specific calendar to a day/month/year.
Julian days outside the specified range are returned as “0/0/0”.
@param CalendarInterface $calendar
@param int $julian_day
@param int $min_jd
@param int $max_jd
@return string | entailment |
public static function jdToGregorian($julian_day)
{
// PHP has different limits on 32 and 64 bit systems.
$MAX_JD = PHP_INT_SIZE == 4 ? 536838866 : 2305843009213661906;
return self::jdToCalendar(self::$gregorian_calendar, $julian_day, 1, $MAX_JD);
} | Converts Julian Day Count to Gregorian date.
Shim implementation of JDToGregorian()
@link https://php.net/JDToGregorian
@param int $julian_day A Julian Day number
@return string A string of the form "month/day/year" | entailment |
public static function jdToJewish($julian_day, $hebrew, $fl)
{
if ($hebrew) {
if ($julian_day < 347998 || $julian_day > 4000075) {
$error_msg = PHP_VERSION_ID < 70200 ? 'Year out of range (0-9999).' : 'Year out of range (0-9999)';
return trigger_error($error_msg,... | Converts a Julian day count to a Jewish calendar date.
Shim implementation of JdtoJjewish()
@link https://php.net/JdtoJewish
@param int $julian_day A Julian Day number
@param bool $hebrew If true, the date is returned in Hebrew text
@param int $fl If $hebrew is true, then add alafim and gereshayim to t... | entailment |
public static function jdToJulian($julian_day)
{
// PHP has different limits on 32 and 64 bit systems.
$MAX_JD = PHP_INT_SIZE == 4 ? 536838829 : 784368370349;
return self::jdToCalendar(self::$julian_calendar, $julian_day, 1, $MAX_JD);
} | Converts a Julian Day Count to a Julian Calendar Date.
Shim implementation of JDToJulian()
@link https://php.net/JDToJulian
@param int $julian_day A Julian Day number
@return string A string of the form "month/day/year" | entailment |
public static function jewishToJd($month, $day, $year)
{
if ($year <= 0) {
return 0;
} else {
return self::$jewish_calendar->ymdToJd($year, $month, $day);
}
} | Converts a date in the Jewish Calendar to Julian Day Count.
Shim implementation of JewishToJD()
@link https://php.net/JewishToJD
@param int $month
@param int $day
@param int $year
@return int | entailment |
public static function julianToJd($month, $day, $year)
{
if ($year == 0) {
return 0;
} else {
return self::$julian_calendar->ymdToJd($year, $month, $day);
}
} | Converts a Julian Calendar date to Julian Day Count.
Shim implementation of JdToJulian()
@link https://php.net/JdToJulian
@param int $month
@param int $day
@param int $year
@return int | entailment |
public static function unixToJd($timestamp)
{
if ($timestamp < 0) {
return false;
} else {
// Convert timestamp based on local timezone
return self::GregorianToJd(gmdate('n', $timestamp), gmdate('j', $timestamp), gmdate('Y', $timestamp));
}
} | Convert Unix timestamp to Julian Day.
Shim implementation of unixtojd()
@link https://php.net/unixtojd
@param int $timestamp
@return false|int | entailment |
public function jdToYmd($julian_day)
{
$year = (int) ((30 * ($julian_day - 1948440) + 10646) / 10631);
$month = (int) ((11 * ($julian_day - $year * 354 - (int) ((3 + 11 * $year) / 30) - 1948086) + 330) / 325);
$day = $julian_day - 29 * ($month - 1) - (int) ((6 * $month - 1) / 11) - $year ... | Convert a Julian day number into a year/month/day.
@param int $julian_day
@return int[] | entailment |
public function ymdToJd($year, $month, $day)
{
if ($month < 1 || $month > $this->monthsInYear()) {
throw new InvalidArgumentException('Month ' . $month . ' is invalid for this calendar');
}
return $day + 29 * ($month - 1) + (int) ((6 * $month - 1) / 11) + $year * 354 + (int) ((3... | Convert a year/month/day to a Julian day number.
@param int $year
@param int $month
@param int $day
@return int | entailment |
public function create(string $name, string $class, array $notAnalyzedFields = []): Repository
{
return new ElasticSearchRepository($this->client, $this->serializer, $name, $class, $notAnalyzedFields);
} | {@inheritDoc} | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.