repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
Eresus/EresusCMS | src/ext-3rd/tinymce/plugins/images/connector/php/exifReader.php | phpExifReader.ProcessExifDir | function ProcessExifDir($DirStart, $OffsetBase, $ExifLength)
{
$NumDirEntries = 0;
$ValuePtr = array();
$NumDirEntries = $this->Get16u($DirStart[0], $DirStart[1]);
$this->debug("<br>Directory with $NumDirEntries entries\n");
for ($de = 0; $de < $NumDirEntries; $de++)
{
//$DirEntry = array_slice($DirStart,2+12*$de);
$DirEntry = substr($DirStart, 2 + 12 * $de);
$Tag = $this->Get16u($DirEntry[0], $DirEntry[1]);
$Format = $this->Get16u($DirEntry[2], $DirEntry[3]);
$Components = $this->Get32u($DirEntry[4], $DirEntry[5], $DirEntry[6], $DirEntry[7]);
/**
if ((Format-1) >= NUM_FORMATS) {
// (-1) catches illegal zero case as unsigned underflows to positive large.
ErrNonfatal("Illegal number format %d for tag %04x", Format, Tag);
continue;
}
*/
$ByteCount = $Components * $this->BytesPerFormat[$Format];
if ($ByteCount > 4)
{
$OffsetVal = $this->Get32u($DirEntry[8], $DirEntry[9], $DirEntry[10], $DirEntry[11]);
if ($OffsetVal + $ByteCount > $ExifLength)
{
$this->debug("Illegal value pointer($OffsetVal) for tag $Tag", 1);
}
//$ValuePtr = array_slice($OffsetBase,$OffsetVal);
$ValuePtr = substr($OffsetBase, $OffsetVal);
}
else
{
//$ValuePtr = array_slice($DirEntry,8);
$ValuePtr = substr($DirEntry, 8);
}
switch ($Tag)
{
case TAG_MAKE:
$this->ImageInfo["h"]["make"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_MODEL:
$this->ImageInfo["h"]["model"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_DATETIME_ORIGINAL:
$this->ImageInfo[TAG_DATETIME_ORIGINAL] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
$this->ImageInfo["h"]["DateTime"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_USERCOMMENT:
// Olympus has this padded with trailing spaces. Remove these first.
for ($a = $ByteCount; ;)
{
$a--;
if ($ValuePtr[$a] == ' ')
{
//$ValuePtr[$a] = '\0';
}
else
{
break;
}
if ($a == 0)
{
break;
}
}
$tmp = '';
// Copy the comment
if (($ValuePtr[0] . $ValuePtr[1] . $ValuePtr[2] . $ValuePtr[3] . $ValuePtr[4]) == "ASCII")
{
for ($a = 5; $a < 10; $a++)
{
$c = $ValuePtr[$a];
if ($c != '\0' && $c != ' ')
{
$tmp = substr($ValuePtr, 0, $ByteCount);
break;
}
}
}
else
{
if (($ValuePtr[0] . $ValuePtr[1] . $ValuePtr[2] . $ValuePtr[3] . $ValuePtr[4] . $ValuePtr[5] . $ValuePtr[6]) == "Unicode")
{
$tmp = substr($ValuePtr, 0, $ByteCount);
// * Handle Unicode characters here...
}
else
{
//$this->ImageInfo[TAG_USERCOMMENT] = implode("",array_slice($ValuePtr,0,$ByteCount));
$tmp = substr($ValuePtr, 0, $ByteCount);
}
}
$this->ImageInfo['h']["exifComment"] = $this->string_format($tmp);
break;
case TAG_ARTIST:
$this->ImageInfo['h']["artist"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_COPYRIGHT:
$this->ImageInfo['h']["copyright"] = htmlentities(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_FNUMBER:
// Simplest way of expressing aperture, so I trust it the most.
// (overwrite previously computd value if there is one)
$tmp = $this->ConvertAnyFormat(substr($ValuePtr, 0), $Format);
$this->ImageInfo['h']["fnumber"] = sprintf("f/%3.1f", (double)$tmp[0]);
break;
case TAG_APERTURE:
case TAG_MAXAPERTURE:
// More relevant info always comes earlier, so only use this field if we don't
// have appropriate aperture information yet.
if (!isset($this->ImageInfo['h']["aperture"]))
{
$tmpArr = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["aperture"] = exp($tmpArr[0] * log(2) * 0.5);
}
break;
case TAG_FOCALLENGTH:
// Nice digital cameras actually save the focal length as a function
// of how farthey are zoomed in.
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["focalLength"] = sprintf("%4.2f (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);
if (isset($this->ImageInfo['h']["CCDWidth"]))
{
$this->ImageInfo['h']["focalLength"] .= sprintf("(35mm equivalent: %dmm)", (int)($tmp[0] / $this->ImageInfo['h']["CCDWidth"] * 36 + 0.5));
}
break;
case TAG_SUBJECT_DISTANCE:
// Inidcates the distacne the autofocus camera is focused to.
// Tends to be less accurate as distance increases.
//$this->ImageInfo["h"]["Distance"] = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["Distance"] = sprintf("%4.2f (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);
if ($this->ImageInfo['h']["Distance"] < 0)
{
$this->ImageInfo['h']["focusDistance"] = "Infinite";
}
else
{
$this->ImageInfo['h']["focusDistance"] = sprintf("%4.2fm", (double)$this->ImageInfo['h']["Distance"]);
}
break;
case TAG_EXPOSURETIME:
// Simplest way of expressing exposure time, so I trust it most.
// (overwrite previously computd value if there is one)
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["exposureTime"] = sprintf("%6.3f s (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);
if ($tmp[0] <= 0.5)
{
$this->ImageInfo['h']["exposureTime"] .= sprintf(" (1/%d)", (int)(0.5 + 1 / $tmp[0]));
}
break;
case TAG_SHUTTERSPEED:
// More complicated way of expressing exposure time, so only use
// this value if we don't already have it from somewhere else.
if (isset($this->ImageInfo['TAG_EXPOSURETIME']) && $this->ImageInfo['TAG_EXPOSURETIME'] == 0)
{
$sp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo[TAG_SHUTTERSPEED] = (1 / exp($sp[0] * log(2)));
}
break;
case TAG_FLASH:
$this->ImageInfo["h"]["flashUsed"] = "No";
if ($this->ConvertAnyFormat($ValuePtr, $Format) & 7)
{
$this->ImageInfo["h"]["flashUsed"] = "Yes";
}
break;
case TAG_ORIENTATION:
$this->ImageInfo[TAG_ORIENTATION] = $this->ConvertAnyFormat($ValuePtr, $Format);
if ($this->ImageInfo[TAG_ORIENTATION] < 1 || $this->ImageInfo[TAG_ORIENTATION] > 8)
{
$this->debug(sprintf("Undefined rotation value %d", $this->ImageInfo[TAG_ORIENTATION], 0), 1);
$this->ImageInfo[TAG_ORIENTATION] = 0;
}
break;
case TAG_EXIF_IMAGELENGTH:
// * Image height
$a = (int)$this->ConvertAnyFormat($ValuePtr, $Format);
if ($this->ExifImageLength < $a)
{
$this->ExifImageLength = $a;
}
$this->ImageInfo[TAG_EXIF_IMAGELENGTH] = $this->ExifImageLength;
$this->ImageInfo["h"]["Height"] = $this->ExifImageLength;
break;
case TAG_EXIF_IMAGEWIDTH:
// Use largest of height and width to deal with images that have been
// rotated to portrait format.
$a = (int)$this->ConvertAnyFormat($ValuePtr, $Format);
if ($this->ExifImageWidth < $a)
{
$this->ExifImageWidth = $a;
}
$this->ImageInfo[TAG_EXIF_IMAGEWIDTH] = $this->ExifImageWidth;
$this->ImageInfo["h"]["Width"] = $this->ExifImageWidth;
break;
case TAG_FOCALPLANEXRES:
$this->FocalplaneXRes = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->FocalplaneXRes = $this->FocalplaneXRes[0];
$this->ImageInfo[TAG_FOCALPLANEXRES] = $this->FocalplaneXRes[0];
break;
case TAG_FOCALPLANEUNITS:
switch ($this->ConvertAnyFormat($ValuePtr, $Format))
{
case 1:
$this->FocalplaneUnits = 25.4;
break; // inch
case 2:
// According to the information I was using, 2 means meters.
// But looking at the Cannon powershot's files, inches is the only
// sensible value.
$this->FocalplaneUnits = 25.4;
break;
case 3:
$this->FocalplaneUnits = 10;
break; // centimeter
case 4:
$this->FocalplaneUnits = 1;
break; // milimeter
case 5:
$this->FocalplaneUnits = .001;
break; // micrometer
}
$this->ImageInfo[TAG_FOCALPLANEUNITS] = $this->FocalplaneUnits;
break;
// Remaining cases contributed by: Volker C. Schoech ([email protected])
case TAG_EXPOSURE_BIAS:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["exposureBias"] = sprintf("%4.2f (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);
break;
case TAG_WHITEBALANCE:
$tmp = (int)$this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("1" => "Sunny", "2" => "fluorescent", "3" => "incandescent");
$this->ImageInfo['h']["whiteBalance"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Cloudy");
break;
case TAG_METERING_MODE:
$tmp = (int)$this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("2" => "center weight", "3" => "spot", "5" => "matrix");
$this->ImageInfo['h']["meteringMode"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_EXPOSURE_PROGRAM:
$tmp = (int)$this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("2" => "program (auto)", "3" => "aperture priority (semi-auto)", "4" => "shutter priority (semi-auto)");
$this->ImageInfo['h']["exposure"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_ISO_EQUIVALENT:
$tmp = (int)$this->ConvertAnyFormat($ValuePtr, $Format);
if ($tmp < 50)
{
$tmp *= 200;
}
$this->ImageInfo['h']["isoEquiv"] = sprintf("%2d", (int)$tmp);
break;
case TAG_COMPRESSION_LEVEL:
$tmp = (int)$this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("1" => "Basic", "2" => "Normal", "4" => "Fine");
$this->ImageInfo['h']["jpegQuality"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_THUMBNAIL_OFFSET:
//$this->ThumbnailOffset = $this->ConvertAnyFormat($ValuePtr, $Format);
//$this->DirWithThumbnailPtrs = $DirStart;
break;
case TAG_THUMBNAIL_LENGTH:
//$this->ThumbnailSize = $this->ConvertAnyFormat($ValuePtr, $Format);
//$this->ImageInfo[TAG_THUMBNAIL_LENGTH] = $this->ThumbnailSize;
break;
//----------------------------------------------
case TAG_IMAGE_DESC:
$this->ImageInfo['h']["imageDesc"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_X_RESOLUTION:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["xResolution"] = sprintf("%4.2f (%d/%d) %s", (double)$tmp[0], $tmp[1][0], $tmp[1][1], $this->ImageInfo['h']["resolutionUnit"]);
break;
case TAG_Y_RESOLUTION:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["yResolution"] = sprintf("%4.2f (%d/%d) %s", (double)$tmp[0], $tmp[1][0], $tmp[1][1], $this->ImageInfo['h']["resolutionUnit"]);
break;
case TAG_RESOLUTION_UNIT:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("2" => "Inches", "3" => "Centimeters");
$this->ImageInfo['h']["resolutionUnit"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_SOFTWARE:
$this->ImageInfo['h']["software"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_FILE_MODDATE;
$this->ImageInfo['h']["fileModifiedDate"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_YCBCR_POSITIONING:
$this->ImageInfo['h']["YCbCrPositioning"] = $this->ConvertAnyFormat($ValuePtr, $Format);
break;
case TAG_EXIF_VERSION:
$this->ImageInfo['h']["exifVersion"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_DATE_TIME_DIGITIZED:
$this->ImageInfo['h']["dateTimeDigitized"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_COMPONENT_CONFIG: // need more tests for this
$tmp = (int)$this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("0" => "Does Not Exists", "1" => "Y", "2" => "Cb", "3" => "Cr", "4" => "R", "5" => "G", "6" => "B");
if (strlen($tmp) < 4)
{
$this->ImageInfo['h']["componentConfig"] = $tmpArr["0"];
}
else
{
for ($i = 0; $i < strlen($tmp); $i++)
{
if ($tmp["$i"] != 0)
{
$this->ImageInfo['h']["componentConfig"] .= $tmpArr[$tmp["$i"]];
}
}
}
break;
case TAG_MAKER_NOTE:
//$this->ImageInfo['h']["makerNote"] = substr($ValuePtr,0,$ByteCount);
$this->ImageInfo['h']["makerNote"] = "NOT IMPLEMENTED";
break;
case TAG_SUB_SEC_TIME:
$this->ImageInfo['h']["subSectionTime"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_SUB_SEC_TIME_ORIG:
$this->ImageInfo['h']["subSectionTimeOriginal"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_SUB_SEC_TIME_DIGITIZED:
$this->ImageInfo['h']["subSectionTimeDigtized"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_FLASHPIX_VER:
$this->ImageInfo['h']["flashpixVersion"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_COLOR_SPACE:
$this->ImageInfo['h']["colorSpace"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_RELATED_SOUND_FILE:
$this->ImageInfo['h']["relatedSoundFile"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_GPS_LATITUDE_REF:
$this->ImageInfo['h']["GPSLatitudeRef"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
$this->ImageInfo['h']["GPSLatitudeRef"] = trim($this->ImageInfo['h']["GPSLatitudeRef"]);
$tmp = substr($this->ImageInfo['h']["GPSLatitudeRef"], 0, 1);
if ($tmp == "S")
{
$this->ImageInfo['h']["GPSLatitudeRef"] = "South latitude";
}
else
{
if ($tmp == "N")
{
$this->ImageInfo['h']["GPSLatitudeRef"] = "North latitude";
}
else
{
$this->ImageInfo['h']["GPSLatitudeRef"] = "Reserved";
}
}
break;
case TAG_GPS_LATITUDE:
$tmp = substr($ValuePtr, 0, $ByteCount);
$this->ImageInfo['h']["GPSLatitude"]["Degrees"] = ord(substr($tmp, 0, 1));
$this->ImageInfo['h']["GPSLatitude"]["Minutes"] = ord(substr($tmp, 1, 1));
$this->ImageInfo['h']["GPSLatitude"]["Seconds"] = ord(substr($tmp, 2, 1));
break;
case TAG_GPS_LONGITUDE:
$tmp = substr($ValuePtr, 0, $ByteCount);
$this->ImageInfo['h']["GPSLongitude"]["Degrees"] = ord(substr($tmp, 0, 1));
$this->ImageInfo['h']["GPSLongitude"]["Minutes"] = ord(substr($tmp, 1, 1));
$this->ImageInfo['h']["GPSLongitude"]["Seconds"] = ord(substr($tmp, 2, 1));
break;
case TAG_GPS_LONGITUDE_REF:
$this->ImageInfo['h']["GPSLongitudeRef"] = substr($ValuePtr, 0, $ByteCount);
$this->ImageInfo['h']["GPSLongitudeRef"] = trim($this->ImageInfo['h']["GPSLongitudeRef"]);
$tmp = substr($this->ImageInfo['h']["GPSLongitudeRef"], 0, 1);
if ($tmp == "E")
{
$this->ImageInfo['h']["GPSLongitudeRef"] = "East Longitude";
}
else
{
if ($tmp == "W")
{
$this->ImageInfo['h']["GPSLongitudeRef"] = "West Longitude";
}
else
{
$this->ImageInfo['h']["GPSLongitudeRef"] = "Reserved";
}
}
break;
case TAG_GPS_TrackRef: /* Reference for direction of movement GPSTrackRef */
$this->ImageInfo['h']["GPSTrackRef"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_GPS_GPSTrack: /* Direction of movement GPSTrack */
$this->ImageInfo['h']["GPSTrack"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_GPS_GPSImgDirectionRef: /* Reference for direction of image GPSImgDirectionRef */
$this->ImageInfo['h']["GPSImgDirectionRef"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_GPS_GPSImgDirection: /* Direction of image GPSImgDirection */
$this->ImageInfo['h']["GPSImgDirection"] = $this->ConvertAnyFormat($ValuePtr, $Format);
break;
case TAG_GPS_GPSMapDatum: /* Geodetic survey data used GPSMapDatum */
$this->ImageInfo['h']["GPSMapDatum"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_GPS_GPSDestLatitudeRef: /* Reference for latitude of destination GPSDestLatitudeRef */
$this->ImageInfo['h']["GPSDestLatitudeRef"] = substr($ValuePtr, 0, $ByteCount);
$this->ImageInfo['h']["GPSDestLatitudeRef"] = trim($this->ImageInfo['h']["GPSDestLatitudeRef"]);
$tmp = substr($this->ImageInfo['h']["GPSDestLatitudeRef"], 0, 1);
if ($tmp == "S")
{
$this->ImageInfo['h']["GPSDestLatitudeRef"] = "South latitude";
}
else
{
if ($tmp == "N")
{
$this->ImageInfo['h']["GPSDestLatitudeRef"] = "North latitude";
}
else
{
$this->ImageInfo['h']["GPSDestLatitudeRef"] = "Reserved";
}
}
break;
case TAG_GPS_GPSDestLatitude: /* Latitude of destination GPSDestLatitude */
$tmp = substr($ValuePtr, 0, $ByteCount);
$this->ImageInfo['h']["GPSDestLatitude"]["Degrees"] = ord(substr($tmp, 0, 1));
$this->ImageInfo['h']["GPSDestLatitude"]["Minutes"] = ord(substr($tmp, 1, 1));
$this->ImageInfo['h']["GPSDestLatitude"]["Seconds"] = ord(substr($tmp, 2, 1));
break;
case TAG_GPS_GPSDestLongitudeRef: /* Reference for longitude of destination GPSDestLongitudeRef 21 */
$this->ImageInfo['h']["GPSDestLongitudeRef"] = substr($ValuePtr, 0, $ByteCount);
$this->ImageInfo['h']["GPSDestLongitudeRef"] = trim($this->ImageInfo['h']["GPSDestLongitudeRef"]);
$tmp = substr($this->ImageInfo['h']["GPSDestLongitudeRef"], 0, 1);
if ($tmp == "E")
{
$this->ImageInfo['h']["GPSDestLongitudeRef"] = "East Longitude";
}
else
{
if ($tmp == "W")
{
$this->ImageInfo['h']["GPSDestLongitudeRef"] = "West Longitude";
}
else
{
$this->ImageInfo['h']["GPSDestLongitudeRef"] = "Reserved";
}
}
break;
case TAG_GPS_GPSDestLongitude: /* Longitude of destination GPSDestLongitude 22 */
$this->ImageInfo['h']["GPSDestLongitude"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_GPS_GPSDestBearingRef: /* Reference for bearing of destination GPSDestBearingRef 23 */
$this->ImageInfo['h']["GPSDestBearingRef"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_GPS_GPSDestBearing: /* Bearing of destination GPSDestBearing 24 */
$this->ImageInfo['h']["GPSDestBearing"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_GPS_GPSDestDistanceRef: /* Reference for distance to destination GPSDestDistanceRef 25 */
$this->ImageInfo['h']["GPSDestDistanceRef"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_GPS_GPSDestDistance: /* Distance to destination GPSDestDistance 26 */
//$this->ImageInfo['h']["GPSDestDistance"] = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["GPSDestDistance"] = sprintf("%4.2f (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);;
break;
case TAG_GPS_GPSProcessingMethod: /* Name of GPS processing method GPSProcessingMethod 27 */
//$this->ImageInfo['h']["GPSProcessingMethod"] = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["GPSProcessingMethod"] = sprintf("%4.2f (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);;
break;
case TAG_GPS_GPSAreaInformation: /* Name of GPS area GPSAreaInformation 28 */
$this->ImageInfo['h']["GPSAreaInformation"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_GPS_GPSDateStamp: /* GPS date GPSDateStamp 29 */
$this->ImageInfo['h']["GPSDateStamp"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_GPS_GPSDifferential: /* GPS differential correction GPSDifferential 30 */
$this->ImageInfo['h']["GPSDifferential"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_AUDIO_MU_LAW:
$this->ImageInfo['h']["AudioMuLaw"] = $this->ConvertAnyFormat($ValuePtr, $Format);
break;
case TAG_AUDIO_IMA_ADPCM_DESC: // IMA-ADPCM Audio File Description Example - 40
$this->ImageInfo['h']["AudioIMA-ADPCM-DESC"] = $this->ConvertAnyFormat($ValuePtr, $Format);
break;
case TAG_AUDIO_MU_LAW_DESC: // µ-Law Audio File Description Sample - 50
$this->ImageInfo['h']["AudioMuLawDesc"] = $this->ConvertAnyFormat($ValuePtr, $Format);
break;
case TAG_EXPOSURE_INDEX:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["ExposureIndex"] = sprintf("%4.2f (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);;
break;
case TAG_SENSING_METHOD:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("1" => "Not Defined", "2" => "One-chip color area sensor", "3" => "Two-chip color area sensor",
"4" => "Three -chip color area sensor", "5" => "Color sequential area sensor",
"6" => "Trilinear sensor", "7" => "Color sequential linear sensor"
);
$this->ImageInfo['h']["sensing"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_SOUCE_TYPE:
$this->ImageInfo['h']["sourceType"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_SCENE_TYPE:
$this->ImageInfo['h']["sceneType"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_CFA_PATTERN:
$this->ImageInfo['h']["CFAPattern"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_CUSTOM_RENDERED:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["customRendered"] = ($tmp == 0) ? 'Normal Process' : ($tmp == 1 ? 'Custom Process' : 'Reserved');
break;
case TAG_EXPOSURE_MODE:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array('Auto Exposure', 'Manual Exposure', 'Auto Bracket');
$this->ImageInfo['h']["exposureMode"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_WHITE_BALANCE:
$this->ImageInfo['h']["whiteBalance"] = $this->ConvertAnyFormat($ValuePtr, $Format);
break;
case TAG_DIGITAL_ZOOM_RATIO:
$tmp = $this->ImageInfo['h']["zoomRatio"] = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["zoomRatio"] = sprintf("%4.2f (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);
break;
case TAG_FLENGTH_IN35MM:
$this->ImageInfo['h']["flength35mm"] = $this->ConvertAnyFormat($ValuePtr, $Format);
break;
case TAG_SCREEN_CAP_TYPE:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("Standard", "Landscape", "Portrait", "Night Scene");
$this->ImageInfo['h']["screenCaptureType"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_GAIN_CONTROL:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("None", "Low Gain Up", "High Gain Up", "Low Gain Down", "High Gain Down");
$this->ImageInfo['h']["gainControl"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_CONTRAST:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("Normal", "Soft", "Hard");
$this->ImageInfo['h']["contrast"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_SATURATION:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("Normal", "Low Saturation", "High Saturation");
$this->ImageInfo['h']["saturation"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_SHARPNESS:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("Normal", "Soft", "Hard");
$this->ImageInfo['h']["sharpness"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_DIST_RANGE:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("Unknown", "Macro", "Close View", "Distant View");
$this->ImageInfo['h']["distanceRange"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_DEVICE_SETTING_DESC:
/*
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("Unknown","Macro","Close View","Distant View");
$this->ImageInfo['h']["distanceRange"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
*/
$this->ImageInfo['h']["deviceSettingDesc"] = "NOT IMPLEMENTED";
break;
case TAG_COMPRESS_SCHEME:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("1" => "Uncompressed", "6" => "JPEG compression (thumbnails only)");
$this->ImageInfo['h']["compressScheme"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_IMAGE_WD:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["jpegImageWidth"] = $tmp;
break;
case TAG_IMAGE_HT:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["jpegImageHeight"] = $tmp;
break;
case TAG_IMAGE_BPS:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["jpegBitsPerSample"] = $tmp;
break;
case TAG_IMAGE_PHOTO_INT:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["jpegPhotometricInt"] = $tmp;
$tmpArr = array("2" => "RGB", "6" => "YCbCr");
$this->ImageInfo['h']["jpegPhotometricInt"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_IMAGE_SOFFSET:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["jpegStripOffsets"] = $tmp;
break;
case TAG_IMAGE_SPP:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["jpegSamplesPerPixel"] = $tmp;
break;
case TAG_IMAGE_RPS:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["jpegRowsPerStrip"] = $tmp;
break;
case TAG_IMAGE_SBC:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["jpegStripByteCounts"] = $tmp;
break;
case TAG_IMAGE_P_CONFIG:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("1" => "Chunky Format", "2" => "Planar Format");
$this->ImageInfo['h']["jpegPlanarConfig"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_FOCALPLANE_YRESOL:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["focalPlaneYResolution"] = sprintf("%4.2f (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);
break;
case TAG_BRIGHTNESS:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["brightness"] = sprintf("%4.2f (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);
break;
//---------------------------------------------
case TAG_EXIF_OFFSET:
case TAG_INTEROP_OFFSET:
{
$SubdirStart = substr($OffsetBase, $this->Get32u($ValuePtr[0], $ValuePtr[1], $ValuePtr[2], $ValuePtr[3]));
//if ($SubdirStart < $OffsetBase || $SubdirStart > $OffsetBase+$ExifLength){
// debug("Illegal exif or interop ofset directory link",1);
//}else{
//echo "<h1>Calling sub-exif dir</h1>";
$this->ProcessExifDir($SubdirStart, $OffsetBase, $ExifLength);
//}
continue;
}
default:
{
$this->debug("UNKNOWN TAG: $Tag");
}
}
}
{
// In addition to linking to subdirectories via exif tags,
// there's also a potential link to another directory at the end of each
// directory. this has got to be the result of a comitee!
$tmpDirStart = substr($DirStart, 2 + 12 * $NumDirEntries);
if (strlen($tmpDirStart) + 4 <= strlen($OffsetBase) + $ExifLength)
{
$Offset = $this->Get32u($tmpDirStart[0], $tmpDirStart[1], $tmpDirStart[2], $tmpDirStart[3]);
if ($Offset)
{
$SubdirStart = substr($OffsetBase, $Offset);
if (strlen($SubdirStart) > strlen($OffsetBase) + $ExifLength)
{
if (strlen($SubdirStart) < strlen($OffsetBase) + $ExifLength + 20)
{
// Jhead 1.3 or earlier would crop the whole directory!
// As Jhead produces this form of format incorrectness,
// I'll just let it pass silently
}
else
{
$this->errno = 51;
$this->errstr = "Illegal subdirectory link";
$this->debug($this->errstr, 1);
}
}
else
{
if (strlen($SubdirStart) <= strlen($OffsetBase) + $ExifLength)
{
$this->ProcessExifDir($SubdirStart, $OffsetBase, $ExifLength);
}
}
}
}
else
{
// The exif header ends before the last next directory pointer.
}
}
/**
* Check if thumbnail has been cached or not.
* If yes! then read the file.
*/
/*
if(file_exists($this->thumbnail) && $this->caching && (filemtime($this->thumbnail) == filemtime($this->file) )) {
$this->ImageInfo["h"]["Thumbnail"] = $this->thumbnail;
$this->ImageInfo["h"]["ThumbnailSize"] = sprintf("%d bytes",filesize($this->thumbnail));
} else{
if ($this->ThumbnailSize && $this->ThumbnailOffset){
if ($this->ThumbnailSize + $this->ThumbnailOffset <= $ExifLength){
// The thumbnail pointer appears to be valid. Store it.
$this->ImageInfo["h"]["Thumbnail"] = substr($OffsetBase,$this->ThumbnailOffset);
// Save the thumbnail /
if($this->caching && is_dir($this->cacheDir)) {
$this->saveThumbnail($this->thumbnail);
$this->ImageInfo["h"]["Thumbnail"] = $this->thumbnail;
}
$this->ImageInfo["h"]["ThumbnailSize"] = sprintf("%d bytes",strlen($this->ImageInfo["h"]["Thumbnail"]));
}
}
}
*/
} | php | function ProcessExifDir($DirStart, $OffsetBase, $ExifLength)
{
$NumDirEntries = 0;
$ValuePtr = array();
$NumDirEntries = $this->Get16u($DirStart[0], $DirStart[1]);
$this->debug("<br>Directory with $NumDirEntries entries\n");
for ($de = 0; $de < $NumDirEntries; $de++)
{
//$DirEntry = array_slice($DirStart,2+12*$de);
$DirEntry = substr($DirStart, 2 + 12 * $de);
$Tag = $this->Get16u($DirEntry[0], $DirEntry[1]);
$Format = $this->Get16u($DirEntry[2], $DirEntry[3]);
$Components = $this->Get32u($DirEntry[4], $DirEntry[5], $DirEntry[6], $DirEntry[7]);
/**
if ((Format-1) >= NUM_FORMATS) {
// (-1) catches illegal zero case as unsigned underflows to positive large.
ErrNonfatal("Illegal number format %d for tag %04x", Format, Tag);
continue;
}
*/
$ByteCount = $Components * $this->BytesPerFormat[$Format];
if ($ByteCount > 4)
{
$OffsetVal = $this->Get32u($DirEntry[8], $DirEntry[9], $DirEntry[10], $DirEntry[11]);
if ($OffsetVal + $ByteCount > $ExifLength)
{
$this->debug("Illegal value pointer($OffsetVal) for tag $Tag", 1);
}
//$ValuePtr = array_slice($OffsetBase,$OffsetVal);
$ValuePtr = substr($OffsetBase, $OffsetVal);
}
else
{
//$ValuePtr = array_slice($DirEntry,8);
$ValuePtr = substr($DirEntry, 8);
}
switch ($Tag)
{
case TAG_MAKE:
$this->ImageInfo["h"]["make"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_MODEL:
$this->ImageInfo["h"]["model"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_DATETIME_ORIGINAL:
$this->ImageInfo[TAG_DATETIME_ORIGINAL] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
$this->ImageInfo["h"]["DateTime"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_USERCOMMENT:
// Olympus has this padded with trailing spaces. Remove these first.
for ($a = $ByteCount; ;)
{
$a--;
if ($ValuePtr[$a] == ' ')
{
//$ValuePtr[$a] = '\0';
}
else
{
break;
}
if ($a == 0)
{
break;
}
}
$tmp = '';
// Copy the comment
if (($ValuePtr[0] . $ValuePtr[1] . $ValuePtr[2] . $ValuePtr[3] . $ValuePtr[4]) == "ASCII")
{
for ($a = 5; $a < 10; $a++)
{
$c = $ValuePtr[$a];
if ($c != '\0' && $c != ' ')
{
$tmp = substr($ValuePtr, 0, $ByteCount);
break;
}
}
}
else
{
if (($ValuePtr[0] . $ValuePtr[1] . $ValuePtr[2] . $ValuePtr[3] . $ValuePtr[4] . $ValuePtr[5] . $ValuePtr[6]) == "Unicode")
{
$tmp = substr($ValuePtr, 0, $ByteCount);
// * Handle Unicode characters here...
}
else
{
//$this->ImageInfo[TAG_USERCOMMENT] = implode("",array_slice($ValuePtr,0,$ByteCount));
$tmp = substr($ValuePtr, 0, $ByteCount);
}
}
$this->ImageInfo['h']["exifComment"] = $this->string_format($tmp);
break;
case TAG_ARTIST:
$this->ImageInfo['h']["artist"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_COPYRIGHT:
$this->ImageInfo['h']["copyright"] = htmlentities(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_FNUMBER:
// Simplest way of expressing aperture, so I trust it the most.
// (overwrite previously computd value if there is one)
$tmp = $this->ConvertAnyFormat(substr($ValuePtr, 0), $Format);
$this->ImageInfo['h']["fnumber"] = sprintf("f/%3.1f", (double)$tmp[0]);
break;
case TAG_APERTURE:
case TAG_MAXAPERTURE:
// More relevant info always comes earlier, so only use this field if we don't
// have appropriate aperture information yet.
if (!isset($this->ImageInfo['h']["aperture"]))
{
$tmpArr = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["aperture"] = exp($tmpArr[0] * log(2) * 0.5);
}
break;
case TAG_FOCALLENGTH:
// Nice digital cameras actually save the focal length as a function
// of how farthey are zoomed in.
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["focalLength"] = sprintf("%4.2f (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);
if (isset($this->ImageInfo['h']["CCDWidth"]))
{
$this->ImageInfo['h']["focalLength"] .= sprintf("(35mm equivalent: %dmm)", (int)($tmp[0] / $this->ImageInfo['h']["CCDWidth"] * 36 + 0.5));
}
break;
case TAG_SUBJECT_DISTANCE:
// Inidcates the distacne the autofocus camera is focused to.
// Tends to be less accurate as distance increases.
//$this->ImageInfo["h"]["Distance"] = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["Distance"] = sprintf("%4.2f (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);
if ($this->ImageInfo['h']["Distance"] < 0)
{
$this->ImageInfo['h']["focusDistance"] = "Infinite";
}
else
{
$this->ImageInfo['h']["focusDistance"] = sprintf("%4.2fm", (double)$this->ImageInfo['h']["Distance"]);
}
break;
case TAG_EXPOSURETIME:
// Simplest way of expressing exposure time, so I trust it most.
// (overwrite previously computd value if there is one)
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["exposureTime"] = sprintf("%6.3f s (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);
if ($tmp[0] <= 0.5)
{
$this->ImageInfo['h']["exposureTime"] .= sprintf(" (1/%d)", (int)(0.5 + 1 / $tmp[0]));
}
break;
case TAG_SHUTTERSPEED:
// More complicated way of expressing exposure time, so only use
// this value if we don't already have it from somewhere else.
if (isset($this->ImageInfo['TAG_EXPOSURETIME']) && $this->ImageInfo['TAG_EXPOSURETIME'] == 0)
{
$sp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo[TAG_SHUTTERSPEED] = (1 / exp($sp[0] * log(2)));
}
break;
case TAG_FLASH:
$this->ImageInfo["h"]["flashUsed"] = "No";
if ($this->ConvertAnyFormat($ValuePtr, $Format) & 7)
{
$this->ImageInfo["h"]["flashUsed"] = "Yes";
}
break;
case TAG_ORIENTATION:
$this->ImageInfo[TAG_ORIENTATION] = $this->ConvertAnyFormat($ValuePtr, $Format);
if ($this->ImageInfo[TAG_ORIENTATION] < 1 || $this->ImageInfo[TAG_ORIENTATION] > 8)
{
$this->debug(sprintf("Undefined rotation value %d", $this->ImageInfo[TAG_ORIENTATION], 0), 1);
$this->ImageInfo[TAG_ORIENTATION] = 0;
}
break;
case TAG_EXIF_IMAGELENGTH:
// * Image height
$a = (int)$this->ConvertAnyFormat($ValuePtr, $Format);
if ($this->ExifImageLength < $a)
{
$this->ExifImageLength = $a;
}
$this->ImageInfo[TAG_EXIF_IMAGELENGTH] = $this->ExifImageLength;
$this->ImageInfo["h"]["Height"] = $this->ExifImageLength;
break;
case TAG_EXIF_IMAGEWIDTH:
// Use largest of height and width to deal with images that have been
// rotated to portrait format.
$a = (int)$this->ConvertAnyFormat($ValuePtr, $Format);
if ($this->ExifImageWidth < $a)
{
$this->ExifImageWidth = $a;
}
$this->ImageInfo[TAG_EXIF_IMAGEWIDTH] = $this->ExifImageWidth;
$this->ImageInfo["h"]["Width"] = $this->ExifImageWidth;
break;
case TAG_FOCALPLANEXRES:
$this->FocalplaneXRes = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->FocalplaneXRes = $this->FocalplaneXRes[0];
$this->ImageInfo[TAG_FOCALPLANEXRES] = $this->FocalplaneXRes[0];
break;
case TAG_FOCALPLANEUNITS:
switch ($this->ConvertAnyFormat($ValuePtr, $Format))
{
case 1:
$this->FocalplaneUnits = 25.4;
break; // inch
case 2:
// According to the information I was using, 2 means meters.
// But looking at the Cannon powershot's files, inches is the only
// sensible value.
$this->FocalplaneUnits = 25.4;
break;
case 3:
$this->FocalplaneUnits = 10;
break; // centimeter
case 4:
$this->FocalplaneUnits = 1;
break; // milimeter
case 5:
$this->FocalplaneUnits = .001;
break; // micrometer
}
$this->ImageInfo[TAG_FOCALPLANEUNITS] = $this->FocalplaneUnits;
break;
// Remaining cases contributed by: Volker C. Schoech ([email protected])
case TAG_EXPOSURE_BIAS:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["exposureBias"] = sprintf("%4.2f (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);
break;
case TAG_WHITEBALANCE:
$tmp = (int)$this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("1" => "Sunny", "2" => "fluorescent", "3" => "incandescent");
$this->ImageInfo['h']["whiteBalance"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Cloudy");
break;
case TAG_METERING_MODE:
$tmp = (int)$this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("2" => "center weight", "3" => "spot", "5" => "matrix");
$this->ImageInfo['h']["meteringMode"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_EXPOSURE_PROGRAM:
$tmp = (int)$this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("2" => "program (auto)", "3" => "aperture priority (semi-auto)", "4" => "shutter priority (semi-auto)");
$this->ImageInfo['h']["exposure"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_ISO_EQUIVALENT:
$tmp = (int)$this->ConvertAnyFormat($ValuePtr, $Format);
if ($tmp < 50)
{
$tmp *= 200;
}
$this->ImageInfo['h']["isoEquiv"] = sprintf("%2d", (int)$tmp);
break;
case TAG_COMPRESSION_LEVEL:
$tmp = (int)$this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("1" => "Basic", "2" => "Normal", "4" => "Fine");
$this->ImageInfo['h']["jpegQuality"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_THUMBNAIL_OFFSET:
//$this->ThumbnailOffset = $this->ConvertAnyFormat($ValuePtr, $Format);
//$this->DirWithThumbnailPtrs = $DirStart;
break;
case TAG_THUMBNAIL_LENGTH:
//$this->ThumbnailSize = $this->ConvertAnyFormat($ValuePtr, $Format);
//$this->ImageInfo[TAG_THUMBNAIL_LENGTH] = $this->ThumbnailSize;
break;
//----------------------------------------------
case TAG_IMAGE_DESC:
$this->ImageInfo['h']["imageDesc"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_X_RESOLUTION:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["xResolution"] = sprintf("%4.2f (%d/%d) %s", (double)$tmp[0], $tmp[1][0], $tmp[1][1], $this->ImageInfo['h']["resolutionUnit"]);
break;
case TAG_Y_RESOLUTION:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["yResolution"] = sprintf("%4.2f (%d/%d) %s", (double)$tmp[0], $tmp[1][0], $tmp[1][1], $this->ImageInfo['h']["resolutionUnit"]);
break;
case TAG_RESOLUTION_UNIT:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("2" => "Inches", "3" => "Centimeters");
$this->ImageInfo['h']["resolutionUnit"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_SOFTWARE:
$this->ImageInfo['h']["software"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_FILE_MODDATE;
$this->ImageInfo['h']["fileModifiedDate"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_YCBCR_POSITIONING:
$this->ImageInfo['h']["YCbCrPositioning"] = $this->ConvertAnyFormat($ValuePtr, $Format);
break;
case TAG_EXIF_VERSION:
$this->ImageInfo['h']["exifVersion"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_DATE_TIME_DIGITIZED:
$this->ImageInfo['h']["dateTimeDigitized"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_COMPONENT_CONFIG: // need more tests for this
$tmp = (int)$this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("0" => "Does Not Exists", "1" => "Y", "2" => "Cb", "3" => "Cr", "4" => "R", "5" => "G", "6" => "B");
if (strlen($tmp) < 4)
{
$this->ImageInfo['h']["componentConfig"] = $tmpArr["0"];
}
else
{
for ($i = 0; $i < strlen($tmp); $i++)
{
if ($tmp["$i"] != 0)
{
$this->ImageInfo['h']["componentConfig"] .= $tmpArr[$tmp["$i"]];
}
}
}
break;
case TAG_MAKER_NOTE:
//$this->ImageInfo['h']["makerNote"] = substr($ValuePtr,0,$ByteCount);
$this->ImageInfo['h']["makerNote"] = "NOT IMPLEMENTED";
break;
case TAG_SUB_SEC_TIME:
$this->ImageInfo['h']["subSectionTime"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_SUB_SEC_TIME_ORIG:
$this->ImageInfo['h']["subSectionTimeOriginal"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_SUB_SEC_TIME_DIGITIZED:
$this->ImageInfo['h']["subSectionTimeDigtized"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_FLASHPIX_VER:
$this->ImageInfo['h']["flashpixVersion"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_COLOR_SPACE:
$this->ImageInfo['h']["colorSpace"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_RELATED_SOUND_FILE:
$this->ImageInfo['h']["relatedSoundFile"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_GPS_LATITUDE_REF:
$this->ImageInfo['h']["GPSLatitudeRef"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
$this->ImageInfo['h']["GPSLatitudeRef"] = trim($this->ImageInfo['h']["GPSLatitudeRef"]);
$tmp = substr($this->ImageInfo['h']["GPSLatitudeRef"], 0, 1);
if ($tmp == "S")
{
$this->ImageInfo['h']["GPSLatitudeRef"] = "South latitude";
}
else
{
if ($tmp == "N")
{
$this->ImageInfo['h']["GPSLatitudeRef"] = "North latitude";
}
else
{
$this->ImageInfo['h']["GPSLatitudeRef"] = "Reserved";
}
}
break;
case TAG_GPS_LATITUDE:
$tmp = substr($ValuePtr, 0, $ByteCount);
$this->ImageInfo['h']["GPSLatitude"]["Degrees"] = ord(substr($tmp, 0, 1));
$this->ImageInfo['h']["GPSLatitude"]["Minutes"] = ord(substr($tmp, 1, 1));
$this->ImageInfo['h']["GPSLatitude"]["Seconds"] = ord(substr($tmp, 2, 1));
break;
case TAG_GPS_LONGITUDE:
$tmp = substr($ValuePtr, 0, $ByteCount);
$this->ImageInfo['h']["GPSLongitude"]["Degrees"] = ord(substr($tmp, 0, 1));
$this->ImageInfo['h']["GPSLongitude"]["Minutes"] = ord(substr($tmp, 1, 1));
$this->ImageInfo['h']["GPSLongitude"]["Seconds"] = ord(substr($tmp, 2, 1));
break;
case TAG_GPS_LONGITUDE_REF:
$this->ImageInfo['h']["GPSLongitudeRef"] = substr($ValuePtr, 0, $ByteCount);
$this->ImageInfo['h']["GPSLongitudeRef"] = trim($this->ImageInfo['h']["GPSLongitudeRef"]);
$tmp = substr($this->ImageInfo['h']["GPSLongitudeRef"], 0, 1);
if ($tmp == "E")
{
$this->ImageInfo['h']["GPSLongitudeRef"] = "East Longitude";
}
else
{
if ($tmp == "W")
{
$this->ImageInfo['h']["GPSLongitudeRef"] = "West Longitude";
}
else
{
$this->ImageInfo['h']["GPSLongitudeRef"] = "Reserved";
}
}
break;
case TAG_GPS_TrackRef: /* Reference for direction of movement GPSTrackRef */
$this->ImageInfo['h']["GPSTrackRef"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_GPS_GPSTrack: /* Direction of movement GPSTrack */
$this->ImageInfo['h']["GPSTrack"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_GPS_GPSImgDirectionRef: /* Reference for direction of image GPSImgDirectionRef */
$this->ImageInfo['h']["GPSImgDirectionRef"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_GPS_GPSImgDirection: /* Direction of image GPSImgDirection */
$this->ImageInfo['h']["GPSImgDirection"] = $this->ConvertAnyFormat($ValuePtr, $Format);
break;
case TAG_GPS_GPSMapDatum: /* Geodetic survey data used GPSMapDatum */
$this->ImageInfo['h']["GPSMapDatum"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_GPS_GPSDestLatitudeRef: /* Reference for latitude of destination GPSDestLatitudeRef */
$this->ImageInfo['h']["GPSDestLatitudeRef"] = substr($ValuePtr, 0, $ByteCount);
$this->ImageInfo['h']["GPSDestLatitudeRef"] = trim($this->ImageInfo['h']["GPSDestLatitudeRef"]);
$tmp = substr($this->ImageInfo['h']["GPSDestLatitudeRef"], 0, 1);
if ($tmp == "S")
{
$this->ImageInfo['h']["GPSDestLatitudeRef"] = "South latitude";
}
else
{
if ($tmp == "N")
{
$this->ImageInfo['h']["GPSDestLatitudeRef"] = "North latitude";
}
else
{
$this->ImageInfo['h']["GPSDestLatitudeRef"] = "Reserved";
}
}
break;
case TAG_GPS_GPSDestLatitude: /* Latitude of destination GPSDestLatitude */
$tmp = substr($ValuePtr, 0, $ByteCount);
$this->ImageInfo['h']["GPSDestLatitude"]["Degrees"] = ord(substr($tmp, 0, 1));
$this->ImageInfo['h']["GPSDestLatitude"]["Minutes"] = ord(substr($tmp, 1, 1));
$this->ImageInfo['h']["GPSDestLatitude"]["Seconds"] = ord(substr($tmp, 2, 1));
break;
case TAG_GPS_GPSDestLongitudeRef: /* Reference for longitude of destination GPSDestLongitudeRef 21 */
$this->ImageInfo['h']["GPSDestLongitudeRef"] = substr($ValuePtr, 0, $ByteCount);
$this->ImageInfo['h']["GPSDestLongitudeRef"] = trim($this->ImageInfo['h']["GPSDestLongitudeRef"]);
$tmp = substr($this->ImageInfo['h']["GPSDestLongitudeRef"], 0, 1);
if ($tmp == "E")
{
$this->ImageInfo['h']["GPSDestLongitudeRef"] = "East Longitude";
}
else
{
if ($tmp == "W")
{
$this->ImageInfo['h']["GPSDestLongitudeRef"] = "West Longitude";
}
else
{
$this->ImageInfo['h']["GPSDestLongitudeRef"] = "Reserved";
}
}
break;
case TAG_GPS_GPSDestLongitude: /* Longitude of destination GPSDestLongitude 22 */
$this->ImageInfo['h']["GPSDestLongitude"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_GPS_GPSDestBearingRef: /* Reference for bearing of destination GPSDestBearingRef 23 */
$this->ImageInfo['h']["GPSDestBearingRef"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_GPS_GPSDestBearing: /* Bearing of destination GPSDestBearing 24 */
$this->ImageInfo['h']["GPSDestBearing"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_GPS_GPSDestDistanceRef: /* Reference for distance to destination GPSDestDistanceRef 25 */
$this->ImageInfo['h']["GPSDestDistanceRef"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_GPS_GPSDestDistance: /* Distance to destination GPSDestDistance 26 */
//$this->ImageInfo['h']["GPSDestDistance"] = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["GPSDestDistance"] = sprintf("%4.2f (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);;
break;
case TAG_GPS_GPSProcessingMethod: /* Name of GPS processing method GPSProcessingMethod 27 */
//$this->ImageInfo['h']["GPSProcessingMethod"] = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["GPSProcessingMethod"] = sprintf("%4.2f (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);;
break;
case TAG_GPS_GPSAreaInformation: /* Name of GPS area GPSAreaInformation 28 */
$this->ImageInfo['h']["GPSAreaInformation"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_GPS_GPSDateStamp: /* GPS date GPSDateStamp 29 */
$this->ImageInfo['h']["GPSDateStamp"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_GPS_GPSDifferential: /* GPS differential correction GPSDifferential 30 */
$this->ImageInfo['h']["GPSDifferential"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_AUDIO_MU_LAW:
$this->ImageInfo['h']["AudioMuLaw"] = $this->ConvertAnyFormat($ValuePtr, $Format);
break;
case TAG_AUDIO_IMA_ADPCM_DESC: // IMA-ADPCM Audio File Description Example - 40
$this->ImageInfo['h']["AudioIMA-ADPCM-DESC"] = $this->ConvertAnyFormat($ValuePtr, $Format);
break;
case TAG_AUDIO_MU_LAW_DESC: // µ-Law Audio File Description Sample - 50
$this->ImageInfo['h']["AudioMuLawDesc"] = $this->ConvertAnyFormat($ValuePtr, $Format);
break;
case TAG_EXPOSURE_INDEX:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["ExposureIndex"] = sprintf("%4.2f (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);;
break;
case TAG_SENSING_METHOD:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("1" => "Not Defined", "2" => "One-chip color area sensor", "3" => "Two-chip color area sensor",
"4" => "Three -chip color area sensor", "5" => "Color sequential area sensor",
"6" => "Trilinear sensor", "7" => "Color sequential linear sensor"
);
$this->ImageInfo['h']["sensing"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_SOUCE_TYPE:
$this->ImageInfo['h']["sourceType"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_SCENE_TYPE:
$this->ImageInfo['h']["sceneType"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_CFA_PATTERN:
$this->ImageInfo['h']["CFAPattern"] = $this->string_format(substr($ValuePtr, 0, $ByteCount));
break;
case TAG_CUSTOM_RENDERED:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["customRendered"] = ($tmp == 0) ? 'Normal Process' : ($tmp == 1 ? 'Custom Process' : 'Reserved');
break;
case TAG_EXPOSURE_MODE:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array('Auto Exposure', 'Manual Exposure', 'Auto Bracket');
$this->ImageInfo['h']["exposureMode"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_WHITE_BALANCE:
$this->ImageInfo['h']["whiteBalance"] = $this->ConvertAnyFormat($ValuePtr, $Format);
break;
case TAG_DIGITAL_ZOOM_RATIO:
$tmp = $this->ImageInfo['h']["zoomRatio"] = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["zoomRatio"] = sprintf("%4.2f (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);
break;
case TAG_FLENGTH_IN35MM:
$this->ImageInfo['h']["flength35mm"] = $this->ConvertAnyFormat($ValuePtr, $Format);
break;
case TAG_SCREEN_CAP_TYPE:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("Standard", "Landscape", "Portrait", "Night Scene");
$this->ImageInfo['h']["screenCaptureType"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_GAIN_CONTROL:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("None", "Low Gain Up", "High Gain Up", "Low Gain Down", "High Gain Down");
$this->ImageInfo['h']["gainControl"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_CONTRAST:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("Normal", "Soft", "Hard");
$this->ImageInfo['h']["contrast"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_SATURATION:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("Normal", "Low Saturation", "High Saturation");
$this->ImageInfo['h']["saturation"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_SHARPNESS:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("Normal", "Soft", "Hard");
$this->ImageInfo['h']["sharpness"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_DIST_RANGE:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("Unknown", "Macro", "Close View", "Distant View");
$this->ImageInfo['h']["distanceRange"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_DEVICE_SETTING_DESC:
/*
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("Unknown","Macro","Close View","Distant View");
$this->ImageInfo['h']["distanceRange"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
*/
$this->ImageInfo['h']["deviceSettingDesc"] = "NOT IMPLEMENTED";
break;
case TAG_COMPRESS_SCHEME:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("1" => "Uncompressed", "6" => "JPEG compression (thumbnails only)");
$this->ImageInfo['h']["compressScheme"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_IMAGE_WD:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["jpegImageWidth"] = $tmp;
break;
case TAG_IMAGE_HT:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["jpegImageHeight"] = $tmp;
break;
case TAG_IMAGE_BPS:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["jpegBitsPerSample"] = $tmp;
break;
case TAG_IMAGE_PHOTO_INT:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["jpegPhotometricInt"] = $tmp;
$tmpArr = array("2" => "RGB", "6" => "YCbCr");
$this->ImageInfo['h']["jpegPhotometricInt"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_IMAGE_SOFFSET:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["jpegStripOffsets"] = $tmp;
break;
case TAG_IMAGE_SPP:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["jpegSamplesPerPixel"] = $tmp;
break;
case TAG_IMAGE_RPS:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["jpegRowsPerStrip"] = $tmp;
break;
case TAG_IMAGE_SBC:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["jpegStripByteCounts"] = $tmp;
break;
case TAG_IMAGE_P_CONFIG:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("1" => "Chunky Format", "2" => "Planar Format");
$this->ImageInfo['h']["jpegPlanarConfig"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_FOCALPLANE_YRESOL:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["focalPlaneYResolution"] = sprintf("%4.2f (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);
break;
case TAG_BRIGHTNESS:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["brightness"] = sprintf("%4.2f (%d/%d)", (double)$tmp[0], $tmp[1][0], $tmp[1][1]);
break;
//---------------------------------------------
case TAG_EXIF_OFFSET:
case TAG_INTEROP_OFFSET:
{
$SubdirStart = substr($OffsetBase, $this->Get32u($ValuePtr[0], $ValuePtr[1], $ValuePtr[2], $ValuePtr[3]));
//if ($SubdirStart < $OffsetBase || $SubdirStart > $OffsetBase+$ExifLength){
// debug("Illegal exif or interop ofset directory link",1);
//}else{
//echo "<h1>Calling sub-exif dir</h1>";
$this->ProcessExifDir($SubdirStart, $OffsetBase, $ExifLength);
//}
continue;
}
default:
{
$this->debug("UNKNOWN TAG: $Tag");
}
}
}
{
// In addition to linking to subdirectories via exif tags,
// there's also a potential link to another directory at the end of each
// directory. this has got to be the result of a comitee!
$tmpDirStart = substr($DirStart, 2 + 12 * $NumDirEntries);
if (strlen($tmpDirStart) + 4 <= strlen($OffsetBase) + $ExifLength)
{
$Offset = $this->Get32u($tmpDirStart[0], $tmpDirStart[1], $tmpDirStart[2], $tmpDirStart[3]);
if ($Offset)
{
$SubdirStart = substr($OffsetBase, $Offset);
if (strlen($SubdirStart) > strlen($OffsetBase) + $ExifLength)
{
if (strlen($SubdirStart) < strlen($OffsetBase) + $ExifLength + 20)
{
// Jhead 1.3 or earlier would crop the whole directory!
// As Jhead produces this form of format incorrectness,
// I'll just let it pass silently
}
else
{
$this->errno = 51;
$this->errstr = "Illegal subdirectory link";
$this->debug($this->errstr, 1);
}
}
else
{
if (strlen($SubdirStart) <= strlen($OffsetBase) + $ExifLength)
{
$this->ProcessExifDir($SubdirStart, $OffsetBase, $ExifLength);
}
}
}
}
else
{
// The exif header ends before the last next directory pointer.
}
}
/**
* Check if thumbnail has been cached or not.
* If yes! then read the file.
*/
/*
if(file_exists($this->thumbnail) && $this->caching && (filemtime($this->thumbnail) == filemtime($this->file) )) {
$this->ImageInfo["h"]["Thumbnail"] = $this->thumbnail;
$this->ImageInfo["h"]["ThumbnailSize"] = sprintf("%d bytes",filesize($this->thumbnail));
} else{
if ($this->ThumbnailSize && $this->ThumbnailOffset){
if ($this->ThumbnailSize + $this->ThumbnailOffset <= $ExifLength){
// The thumbnail pointer appears to be valid. Store it.
$this->ImageInfo["h"]["Thumbnail"] = substr($OffsetBase,$this->ThumbnailOffset);
// Save the thumbnail /
if($this->caching && is_dir($this->cacheDir)) {
$this->saveThumbnail($this->thumbnail);
$this->ImageInfo["h"]["Thumbnail"] = $this->thumbnail;
}
$this->ImageInfo["h"]["ThumbnailSize"] = sprintf("%d bytes",strlen($this->ImageInfo["h"]["Thumbnail"]));
}
}
}
*/
} | [
"function",
"ProcessExifDir",
"(",
"$",
"DirStart",
",",
"$",
"OffsetBase",
",",
"$",
"ExifLength",
")",
"{",
"$",
"NumDirEntries",
"=",
"0",
";",
"$",
"ValuePtr",
"=",
"array",
"(",
")",
";",
"$",
"NumDirEntries",
"=",
"$",
"this",
"->",
"Get16u",
"(",
"$",
"DirStart",
"[",
"0",
"]",
",",
"$",
"DirStart",
"[",
"1",
"]",
")",
";",
"$",
"this",
"->",
"debug",
"(",
"\"<br>Directory with $NumDirEntries entries\\n\"",
")",
";",
"for",
"(",
"$",
"de",
"=",
"0",
";",
"$",
"de",
"<",
"$",
"NumDirEntries",
";",
"$",
"de",
"++",
")",
"{",
"//$DirEntry = array_slice($DirStart,2+12*$de);",
"$",
"DirEntry",
"=",
"substr",
"(",
"$",
"DirStart",
",",
"2",
"+",
"12",
"*",
"$",
"de",
")",
";",
"$",
"Tag",
"=",
"$",
"this",
"->",
"Get16u",
"(",
"$",
"DirEntry",
"[",
"0",
"]",
",",
"$",
"DirEntry",
"[",
"1",
"]",
")",
";",
"$",
"Format",
"=",
"$",
"this",
"->",
"Get16u",
"(",
"$",
"DirEntry",
"[",
"2",
"]",
",",
"$",
"DirEntry",
"[",
"3",
"]",
")",
";",
"$",
"Components",
"=",
"$",
"this",
"->",
"Get32u",
"(",
"$",
"DirEntry",
"[",
"4",
"]",
",",
"$",
"DirEntry",
"[",
"5",
"]",
",",
"$",
"DirEntry",
"[",
"6",
"]",
",",
"$",
"DirEntry",
"[",
"7",
"]",
")",
";",
"/**\n if ((Format-1) >= NUM_FORMATS) {\n // (-1) catches illegal zero case as unsigned underflows to positive large.\n ErrNonfatal(\"Illegal number format %d for tag %04x\", Format, Tag);\n continue;\n }\n */",
"$",
"ByteCount",
"=",
"$",
"Components",
"*",
"$",
"this",
"->",
"BytesPerFormat",
"[",
"$",
"Format",
"]",
";",
"if",
"(",
"$",
"ByteCount",
">",
"4",
")",
"{",
"$",
"OffsetVal",
"=",
"$",
"this",
"->",
"Get32u",
"(",
"$",
"DirEntry",
"[",
"8",
"]",
",",
"$",
"DirEntry",
"[",
"9",
"]",
",",
"$",
"DirEntry",
"[",
"10",
"]",
",",
"$",
"DirEntry",
"[",
"11",
"]",
")",
";",
"if",
"(",
"$",
"OffsetVal",
"+",
"$",
"ByteCount",
">",
"$",
"ExifLength",
")",
"{",
"$",
"this",
"->",
"debug",
"(",
"\"Illegal value pointer($OffsetVal) for tag $Tag\"",
",",
"1",
")",
";",
"}",
"//$ValuePtr = array_slice($OffsetBase,$OffsetVal);",
"$",
"ValuePtr",
"=",
"substr",
"(",
"$",
"OffsetBase",
",",
"$",
"OffsetVal",
")",
";",
"}",
"else",
"{",
"//$ValuePtr = array_slice($DirEntry,8);",
"$",
"ValuePtr",
"=",
"substr",
"(",
"$",
"DirEntry",
",",
"8",
")",
";",
"}",
"switch",
"(",
"$",
"Tag",
")",
"{",
"case",
"TAG_MAKE",
":",
"$",
"this",
"->",
"ImageInfo",
"[",
"\"h\"",
"]",
"[",
"\"make\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_MODEL",
":",
"$",
"this",
"->",
"ImageInfo",
"[",
"\"h\"",
"]",
"[",
"\"model\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_DATETIME_ORIGINAL",
":",
"$",
"this",
"->",
"ImageInfo",
"[",
"TAG_DATETIME_ORIGINAL",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"\"h\"",
"]",
"[",
"\"DateTime\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_USERCOMMENT",
":",
"// Olympus has this padded with trailing spaces. Remove these first.",
"for",
"(",
"$",
"a",
"=",
"$",
"ByteCount",
";",
";",
")",
"{",
"$",
"a",
"--",
";",
"if",
"(",
"$",
"ValuePtr",
"[",
"$",
"a",
"]",
"==",
"' '",
")",
"{",
"//$ValuePtr[$a] = '\\0';",
"}",
"else",
"{",
"break",
";",
"}",
"if",
"(",
"$",
"a",
"==",
"0",
")",
"{",
"break",
";",
"}",
"}",
"$",
"tmp",
"=",
"''",
";",
"// Copy the comment",
"if",
"(",
"(",
"$",
"ValuePtr",
"[",
"0",
"]",
".",
"$",
"ValuePtr",
"[",
"1",
"]",
".",
"$",
"ValuePtr",
"[",
"2",
"]",
".",
"$",
"ValuePtr",
"[",
"3",
"]",
".",
"$",
"ValuePtr",
"[",
"4",
"]",
")",
"==",
"\"ASCII\"",
")",
"{",
"for",
"(",
"$",
"a",
"=",
"5",
";",
"$",
"a",
"<",
"10",
";",
"$",
"a",
"++",
")",
"{",
"$",
"c",
"=",
"$",
"ValuePtr",
"[",
"$",
"a",
"]",
";",
"if",
"(",
"$",
"c",
"!=",
"'\\0'",
"&&",
"$",
"c",
"!=",
"' '",
")",
"{",
"$",
"tmp",
"=",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
";",
"break",
";",
"}",
"}",
"}",
"else",
"{",
"if",
"(",
"(",
"$",
"ValuePtr",
"[",
"0",
"]",
".",
"$",
"ValuePtr",
"[",
"1",
"]",
".",
"$",
"ValuePtr",
"[",
"2",
"]",
".",
"$",
"ValuePtr",
"[",
"3",
"]",
".",
"$",
"ValuePtr",
"[",
"4",
"]",
".",
"$",
"ValuePtr",
"[",
"5",
"]",
".",
"$",
"ValuePtr",
"[",
"6",
"]",
")",
"==",
"\"Unicode\"",
")",
"{",
"$",
"tmp",
"=",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
";",
"// * Handle Unicode characters here...",
"}",
"else",
"{",
"//$this->ImageInfo[TAG_USERCOMMENT] = implode(\"\",array_slice($ValuePtr,0,$ByteCount));",
"$",
"tmp",
"=",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
";",
"}",
"}",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"exifComment\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"$",
"tmp",
")",
";",
"break",
";",
"case",
"TAG_ARTIST",
":",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"artist\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_COPYRIGHT",
":",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"copyright\"",
"]",
"=",
"htmlentities",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_FNUMBER",
":",
"// Simplest way of expressing aperture, so I trust it the most.",
"// (overwrite previously computd value if there is one)",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
")",
",",
"$",
"Format",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"fnumber\"",
"]",
"=",
"sprintf",
"(",
"\"f/%3.1f\"",
",",
"(",
"double",
")",
"$",
"tmp",
"[",
"0",
"]",
")",
";",
"break",
";",
"case",
"TAG_APERTURE",
":",
"case",
"TAG_MAXAPERTURE",
":",
"// More relevant info always comes earlier, so only use this field if we don't",
"// have appropriate aperture information yet.",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"aperture\"",
"]",
")",
")",
"{",
"$",
"tmpArr",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"aperture\"",
"]",
"=",
"exp",
"(",
"$",
"tmpArr",
"[",
"0",
"]",
"*",
"log",
"(",
"2",
")",
"*",
"0.5",
")",
";",
"}",
"break",
";",
"case",
"TAG_FOCALLENGTH",
":",
"// Nice digital cameras actually save the focal length as a function",
"// of how farthey are zoomed in.",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"focalLength\"",
"]",
"=",
"sprintf",
"(",
"\"%4.2f (%d/%d)\"",
",",
"(",
"double",
")",
"$",
"tmp",
"[",
"0",
"]",
",",
"$",
"tmp",
"[",
"1",
"]",
"[",
"0",
"]",
",",
"$",
"tmp",
"[",
"1",
"]",
"[",
"1",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"CCDWidth\"",
"]",
")",
")",
"{",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"focalLength\"",
"]",
".=",
"sprintf",
"(",
"\"(35mm equivalent: %dmm)\"",
",",
"(",
"int",
")",
"(",
"$",
"tmp",
"[",
"0",
"]",
"/",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"CCDWidth\"",
"]",
"*",
"36",
"+",
"0.5",
")",
")",
";",
"}",
"break",
";",
"case",
"TAG_SUBJECT_DISTANCE",
":",
"// Inidcates the distacne the autofocus camera is focused to.",
"// Tends to be less accurate as distance increases.",
"//$this->ImageInfo[\"h\"][\"Distance\"] = $this->ConvertAnyFormat($ValuePtr, $Format);",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"Distance\"",
"]",
"=",
"sprintf",
"(",
"\"%4.2f (%d/%d)\"",
",",
"(",
"double",
")",
"$",
"tmp",
"[",
"0",
"]",
",",
"$",
"tmp",
"[",
"1",
"]",
"[",
"0",
"]",
",",
"$",
"tmp",
"[",
"1",
"]",
"[",
"1",
"]",
")",
";",
"if",
"(",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"Distance\"",
"]",
"<",
"0",
")",
"{",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"focusDistance\"",
"]",
"=",
"\"Infinite\"",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"focusDistance\"",
"]",
"=",
"sprintf",
"(",
"\"%4.2fm\"",
",",
"(",
"double",
")",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"Distance\"",
"]",
")",
";",
"}",
"break",
";",
"case",
"TAG_EXPOSURETIME",
":",
"// Simplest way of expressing exposure time, so I trust it most.",
"// (overwrite previously computd value if there is one)",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"exposureTime\"",
"]",
"=",
"sprintf",
"(",
"\"%6.3f s (%d/%d)\"",
",",
"(",
"double",
")",
"$",
"tmp",
"[",
"0",
"]",
",",
"$",
"tmp",
"[",
"1",
"]",
"[",
"0",
"]",
",",
"$",
"tmp",
"[",
"1",
"]",
"[",
"1",
"]",
")",
";",
"if",
"(",
"$",
"tmp",
"[",
"0",
"]",
"<=",
"0.5",
")",
"{",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"exposureTime\"",
"]",
".=",
"sprintf",
"(",
"\" (1/%d)\"",
",",
"(",
"int",
")",
"(",
"0.5",
"+",
"1",
"/",
"$",
"tmp",
"[",
"0",
"]",
")",
")",
";",
"}",
"break",
";",
"case",
"TAG_SHUTTERSPEED",
":",
"// More complicated way of expressing exposure time, so only use",
"// this value if we don't already have it from somewhere else.",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"ImageInfo",
"[",
"'TAG_EXPOSURETIME'",
"]",
")",
"&&",
"$",
"this",
"->",
"ImageInfo",
"[",
"'TAG_EXPOSURETIME'",
"]",
"==",
"0",
")",
"{",
"$",
"sp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"TAG_SHUTTERSPEED",
"]",
"=",
"(",
"1",
"/",
"exp",
"(",
"$",
"sp",
"[",
"0",
"]",
"*",
"log",
"(",
"2",
")",
")",
")",
";",
"}",
"break",
";",
"case",
"TAG_FLASH",
":",
"$",
"this",
"->",
"ImageInfo",
"[",
"\"h\"",
"]",
"[",
"\"flashUsed\"",
"]",
"=",
"\"No\"",
";",
"if",
"(",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
"&",
"7",
")",
"{",
"$",
"this",
"->",
"ImageInfo",
"[",
"\"h\"",
"]",
"[",
"\"flashUsed\"",
"]",
"=",
"\"Yes\"",
";",
"}",
"break",
";",
"case",
"TAG_ORIENTATION",
":",
"$",
"this",
"->",
"ImageInfo",
"[",
"TAG_ORIENTATION",
"]",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"if",
"(",
"$",
"this",
"->",
"ImageInfo",
"[",
"TAG_ORIENTATION",
"]",
"<",
"1",
"||",
"$",
"this",
"->",
"ImageInfo",
"[",
"TAG_ORIENTATION",
"]",
">",
"8",
")",
"{",
"$",
"this",
"->",
"debug",
"(",
"sprintf",
"(",
"\"Undefined rotation value %d\"",
",",
"$",
"this",
"->",
"ImageInfo",
"[",
"TAG_ORIENTATION",
"]",
",",
"0",
")",
",",
"1",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"TAG_ORIENTATION",
"]",
"=",
"0",
";",
"}",
"break",
";",
"case",
"TAG_EXIF_IMAGELENGTH",
":",
"// * Image height",
"$",
"a",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"if",
"(",
"$",
"this",
"->",
"ExifImageLength",
"<",
"$",
"a",
")",
"{",
"$",
"this",
"->",
"ExifImageLength",
"=",
"$",
"a",
";",
"}",
"$",
"this",
"->",
"ImageInfo",
"[",
"TAG_EXIF_IMAGELENGTH",
"]",
"=",
"$",
"this",
"->",
"ExifImageLength",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"\"h\"",
"]",
"[",
"\"Height\"",
"]",
"=",
"$",
"this",
"->",
"ExifImageLength",
";",
"break",
";",
"case",
"TAG_EXIF_IMAGEWIDTH",
":",
"// Use largest of height and width to deal with images that have been",
"// rotated to portrait format.",
"$",
"a",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"if",
"(",
"$",
"this",
"->",
"ExifImageWidth",
"<",
"$",
"a",
")",
"{",
"$",
"this",
"->",
"ExifImageWidth",
"=",
"$",
"a",
";",
"}",
"$",
"this",
"->",
"ImageInfo",
"[",
"TAG_EXIF_IMAGEWIDTH",
"]",
"=",
"$",
"this",
"->",
"ExifImageWidth",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"\"h\"",
"]",
"[",
"\"Width\"",
"]",
"=",
"$",
"this",
"->",
"ExifImageWidth",
";",
"break",
";",
"case",
"TAG_FOCALPLANEXRES",
":",
"$",
"this",
"->",
"FocalplaneXRes",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"this",
"->",
"FocalplaneXRes",
"=",
"$",
"this",
"->",
"FocalplaneXRes",
"[",
"0",
"]",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"TAG_FOCALPLANEXRES",
"]",
"=",
"$",
"this",
"->",
"FocalplaneXRes",
"[",
"0",
"]",
";",
"break",
";",
"case",
"TAG_FOCALPLANEUNITS",
":",
"switch",
"(",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
")",
"{",
"case",
"1",
":",
"$",
"this",
"->",
"FocalplaneUnits",
"=",
"25.4",
";",
"break",
";",
"// inch",
"case",
"2",
":",
"// According to the information I was using, 2 means meters.",
"// But looking at the Cannon powershot's files, inches is the only",
"// sensible value.",
"$",
"this",
"->",
"FocalplaneUnits",
"=",
"25.4",
";",
"break",
";",
"case",
"3",
":",
"$",
"this",
"->",
"FocalplaneUnits",
"=",
"10",
";",
"break",
";",
"// centimeter",
"case",
"4",
":",
"$",
"this",
"->",
"FocalplaneUnits",
"=",
"1",
";",
"break",
";",
"// milimeter",
"case",
"5",
":",
"$",
"this",
"->",
"FocalplaneUnits",
"=",
".001",
";",
"break",
";",
"// micrometer",
"}",
"$",
"this",
"->",
"ImageInfo",
"[",
"TAG_FOCALPLANEUNITS",
"]",
"=",
"$",
"this",
"->",
"FocalplaneUnits",
";",
"break",
";",
"// Remaining cases contributed by: Volker C. Schoech ([email protected])",
"case",
"TAG_EXPOSURE_BIAS",
":",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"exposureBias\"",
"]",
"=",
"sprintf",
"(",
"\"%4.2f (%d/%d)\"",
",",
"(",
"double",
")",
"$",
"tmp",
"[",
"0",
"]",
",",
"$",
"tmp",
"[",
"1",
"]",
"[",
"0",
"]",
",",
"$",
"tmp",
"[",
"1",
"]",
"[",
"1",
"]",
")",
";",
"break",
";",
"case",
"TAG_WHITEBALANCE",
":",
"$",
"tmp",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"tmpArr",
"=",
"array",
"(",
"\"1\"",
"=>",
"\"Sunny\"",
",",
"\"2\"",
"=>",
"\"fluorescent\"",
",",
"\"3\"",
"=>",
"\"incandescent\"",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"whiteBalance\"",
"]",
"=",
"(",
"isset",
"(",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
")",
"?",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
":",
"\"Cloudy\"",
")",
";",
"break",
";",
"case",
"TAG_METERING_MODE",
":",
"$",
"tmp",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"tmpArr",
"=",
"array",
"(",
"\"2\"",
"=>",
"\"center weight\"",
",",
"\"3\"",
"=>",
"\"spot\"",
",",
"\"5\"",
"=>",
"\"matrix\"",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"meteringMode\"",
"]",
"=",
"(",
"isset",
"(",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
")",
"?",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
":",
"\"Reserved\"",
")",
";",
"break",
";",
"case",
"TAG_EXPOSURE_PROGRAM",
":",
"$",
"tmp",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"tmpArr",
"=",
"array",
"(",
"\"2\"",
"=>",
"\"program (auto)\"",
",",
"\"3\"",
"=>",
"\"aperture priority (semi-auto)\"",
",",
"\"4\"",
"=>",
"\"shutter priority (semi-auto)\"",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"exposure\"",
"]",
"=",
"(",
"isset",
"(",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
")",
"?",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
":",
"\"Reserved\"",
")",
";",
"break",
";",
"case",
"TAG_ISO_EQUIVALENT",
":",
"$",
"tmp",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"if",
"(",
"$",
"tmp",
"<",
"50",
")",
"{",
"$",
"tmp",
"*=",
"200",
";",
"}",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"isoEquiv\"",
"]",
"=",
"sprintf",
"(",
"\"%2d\"",
",",
"(",
"int",
")",
"$",
"tmp",
")",
";",
"break",
";",
"case",
"TAG_COMPRESSION_LEVEL",
":",
"$",
"tmp",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"tmpArr",
"=",
"array",
"(",
"\"1\"",
"=>",
"\"Basic\"",
",",
"\"2\"",
"=>",
"\"Normal\"",
",",
"\"4\"",
"=>",
"\"Fine\"",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"jpegQuality\"",
"]",
"=",
"(",
"isset",
"(",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
")",
"?",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
":",
"\"Reserved\"",
")",
";",
"break",
";",
"case",
"TAG_THUMBNAIL_OFFSET",
":",
"//$this->ThumbnailOffset = $this->ConvertAnyFormat($ValuePtr, $Format);",
"//$this->DirWithThumbnailPtrs = $DirStart;",
"break",
";",
"case",
"TAG_THUMBNAIL_LENGTH",
":",
"//$this->ThumbnailSize = $this->ConvertAnyFormat($ValuePtr, $Format);",
"//$this->ImageInfo[TAG_THUMBNAIL_LENGTH] = $this->ThumbnailSize;",
"break",
";",
"//----------------------------------------------",
"case",
"TAG_IMAGE_DESC",
":",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"imageDesc\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_X_RESOLUTION",
":",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"xResolution\"",
"]",
"=",
"sprintf",
"(",
"\"%4.2f (%d/%d) %s\"",
",",
"(",
"double",
")",
"$",
"tmp",
"[",
"0",
"]",
",",
"$",
"tmp",
"[",
"1",
"]",
"[",
"0",
"]",
",",
"$",
"tmp",
"[",
"1",
"]",
"[",
"1",
"]",
",",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"resolutionUnit\"",
"]",
")",
";",
"break",
";",
"case",
"TAG_Y_RESOLUTION",
":",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"yResolution\"",
"]",
"=",
"sprintf",
"(",
"\"%4.2f (%d/%d) %s\"",
",",
"(",
"double",
")",
"$",
"tmp",
"[",
"0",
"]",
",",
"$",
"tmp",
"[",
"1",
"]",
"[",
"0",
"]",
",",
"$",
"tmp",
"[",
"1",
"]",
"[",
"1",
"]",
",",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"resolutionUnit\"",
"]",
")",
";",
"break",
";",
"case",
"TAG_RESOLUTION_UNIT",
":",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"tmpArr",
"=",
"array",
"(",
"\"2\"",
"=>",
"\"Inches\"",
",",
"\"3\"",
"=>",
"\"Centimeters\"",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"resolutionUnit\"",
"]",
"=",
"(",
"isset",
"(",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
")",
"?",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
":",
"\"Reserved\"",
")",
";",
"break",
";",
"case",
"TAG_SOFTWARE",
":",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"software\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_FILE_MODDATE",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"fileModifiedDate\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_YCBCR_POSITIONING",
":",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"YCbCrPositioning\"",
"]",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"break",
";",
"case",
"TAG_EXIF_VERSION",
":",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"exifVersion\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_DATE_TIME_DIGITIZED",
":",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"dateTimeDigitized\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_COMPONENT_CONFIG",
":",
"// need more tests for this",
"$",
"tmp",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"tmpArr",
"=",
"array",
"(",
"\"0\"",
"=>",
"\"Does Not Exists\"",
",",
"\"1\"",
"=>",
"\"Y\"",
",",
"\"2\"",
"=>",
"\"Cb\"",
",",
"\"3\"",
"=>",
"\"Cr\"",
",",
"\"4\"",
"=>",
"\"R\"",
",",
"\"5\"",
"=>",
"\"G\"",
",",
"\"6\"",
"=>",
"\"B\"",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"tmp",
")",
"<",
"4",
")",
"{",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"componentConfig\"",
"]",
"=",
"$",
"tmpArr",
"[",
"\"0\"",
"]",
";",
"}",
"else",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"strlen",
"(",
"$",
"tmp",
")",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"tmp",
"[",
"\"$i\"",
"]",
"!=",
"0",
")",
"{",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"componentConfig\"",
"]",
".=",
"$",
"tmpArr",
"[",
"$",
"tmp",
"[",
"\"$i\"",
"]",
"]",
";",
"}",
"}",
"}",
"break",
";",
"case",
"TAG_MAKER_NOTE",
":",
"//$this->ImageInfo['h'][\"makerNote\"] = substr($ValuePtr,0,$ByteCount);",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"makerNote\"",
"]",
"=",
"\"NOT IMPLEMENTED\"",
";",
"break",
";",
"case",
"TAG_SUB_SEC_TIME",
":",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"subSectionTime\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_SUB_SEC_TIME_ORIG",
":",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"subSectionTimeOriginal\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_SUB_SEC_TIME_DIGITIZED",
":",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"subSectionTimeDigtized\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_FLASHPIX_VER",
":",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"flashpixVersion\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_COLOR_SPACE",
":",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"colorSpace\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_RELATED_SOUND_FILE",
":",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"relatedSoundFile\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_GPS_LATITUDE_REF",
":",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSLatitudeRef\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSLatitudeRef\"",
"]",
"=",
"trim",
"(",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSLatitudeRef\"",
"]",
")",
";",
"$",
"tmp",
"=",
"substr",
"(",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSLatitudeRef\"",
"]",
",",
"0",
",",
"1",
")",
";",
"if",
"(",
"$",
"tmp",
"==",
"\"S\"",
")",
"{",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSLatitudeRef\"",
"]",
"=",
"\"South latitude\"",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"tmp",
"==",
"\"N\"",
")",
"{",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSLatitudeRef\"",
"]",
"=",
"\"North latitude\"",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSLatitudeRef\"",
"]",
"=",
"\"Reserved\"",
";",
"}",
"}",
"break",
";",
"case",
"TAG_GPS_LATITUDE",
":",
"$",
"tmp",
"=",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSLatitude\"",
"]",
"[",
"\"Degrees\"",
"]",
"=",
"ord",
"(",
"substr",
"(",
"$",
"tmp",
",",
"0",
",",
"1",
")",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSLatitude\"",
"]",
"[",
"\"Minutes\"",
"]",
"=",
"ord",
"(",
"substr",
"(",
"$",
"tmp",
",",
"1",
",",
"1",
")",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSLatitude\"",
"]",
"[",
"\"Seconds\"",
"]",
"=",
"ord",
"(",
"substr",
"(",
"$",
"tmp",
",",
"2",
",",
"1",
")",
")",
";",
"break",
";",
"case",
"TAG_GPS_LONGITUDE",
":",
"$",
"tmp",
"=",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSLongitude\"",
"]",
"[",
"\"Degrees\"",
"]",
"=",
"ord",
"(",
"substr",
"(",
"$",
"tmp",
",",
"0",
",",
"1",
")",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSLongitude\"",
"]",
"[",
"\"Minutes\"",
"]",
"=",
"ord",
"(",
"substr",
"(",
"$",
"tmp",
",",
"1",
",",
"1",
")",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSLongitude\"",
"]",
"[",
"\"Seconds\"",
"]",
"=",
"ord",
"(",
"substr",
"(",
"$",
"tmp",
",",
"2",
",",
"1",
")",
")",
";",
"break",
";",
"case",
"TAG_GPS_LONGITUDE_REF",
":",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSLongitudeRef\"",
"]",
"=",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSLongitudeRef\"",
"]",
"=",
"trim",
"(",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSLongitudeRef\"",
"]",
")",
";",
"$",
"tmp",
"=",
"substr",
"(",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSLongitudeRef\"",
"]",
",",
"0",
",",
"1",
")",
";",
"if",
"(",
"$",
"tmp",
"==",
"\"E\"",
")",
"{",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSLongitudeRef\"",
"]",
"=",
"\"East Longitude\"",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"tmp",
"==",
"\"W\"",
")",
"{",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSLongitudeRef\"",
"]",
"=",
"\"West Longitude\"",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSLongitudeRef\"",
"]",
"=",
"\"Reserved\"",
";",
"}",
"}",
"break",
";",
"case",
"TAG_GPS_TrackRef",
":",
"/* Reference for direction of movement GPSTrackRef */",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSTrackRef\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_GPS_GPSTrack",
":",
"/* Direction of movement\t\t\t\t\tGPSTrack */",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSTrack\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_GPS_GPSImgDirectionRef",
":",
"/* Reference for direction of image GPSImgDirectionRef */",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSImgDirectionRef\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_GPS_GPSImgDirection",
":",
"/* Direction of image GPSImgDirection */",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSImgDirection\"",
"]",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"break",
";",
"case",
"TAG_GPS_GPSMapDatum",
":",
"/* Geodetic survey data used GPSMapDatum */",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSMapDatum\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_GPS_GPSDestLatitudeRef",
":",
"/* Reference for latitude of destination GPSDestLatitudeRef */",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSDestLatitudeRef\"",
"]",
"=",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSDestLatitudeRef\"",
"]",
"=",
"trim",
"(",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSDestLatitudeRef\"",
"]",
")",
";",
"$",
"tmp",
"=",
"substr",
"(",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSDestLatitudeRef\"",
"]",
",",
"0",
",",
"1",
")",
";",
"if",
"(",
"$",
"tmp",
"==",
"\"S\"",
")",
"{",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSDestLatitudeRef\"",
"]",
"=",
"\"South latitude\"",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"tmp",
"==",
"\"N\"",
")",
"{",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSDestLatitudeRef\"",
"]",
"=",
"\"North latitude\"",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSDestLatitudeRef\"",
"]",
"=",
"\"Reserved\"",
";",
"}",
"}",
"break",
";",
"case",
"TAG_GPS_GPSDestLatitude",
":",
"/* Latitude of destination GPSDestLatitude */",
"$",
"tmp",
"=",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSDestLatitude\"",
"]",
"[",
"\"Degrees\"",
"]",
"=",
"ord",
"(",
"substr",
"(",
"$",
"tmp",
",",
"0",
",",
"1",
")",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSDestLatitude\"",
"]",
"[",
"\"Minutes\"",
"]",
"=",
"ord",
"(",
"substr",
"(",
"$",
"tmp",
",",
"1",
",",
"1",
")",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSDestLatitude\"",
"]",
"[",
"\"Seconds\"",
"]",
"=",
"ord",
"(",
"substr",
"(",
"$",
"tmp",
",",
"2",
",",
"1",
")",
")",
";",
"break",
";",
"case",
"TAG_GPS_GPSDestLongitudeRef",
":",
"/* Reference for longitude of destination GPSDestLongitudeRef 21 */",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSDestLongitudeRef\"",
"]",
"=",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSDestLongitudeRef\"",
"]",
"=",
"trim",
"(",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSDestLongitudeRef\"",
"]",
")",
";",
"$",
"tmp",
"=",
"substr",
"(",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSDestLongitudeRef\"",
"]",
",",
"0",
",",
"1",
")",
";",
"if",
"(",
"$",
"tmp",
"==",
"\"E\"",
")",
"{",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSDestLongitudeRef\"",
"]",
"=",
"\"East Longitude\"",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"tmp",
"==",
"\"W\"",
")",
"{",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSDestLongitudeRef\"",
"]",
"=",
"\"West Longitude\"",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSDestLongitudeRef\"",
"]",
"=",
"\"Reserved\"",
";",
"}",
"}",
"break",
";",
"case",
"TAG_GPS_GPSDestLongitude",
":",
"/* Longitude of destination GPSDestLongitude 22 */",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSDestLongitude\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_GPS_GPSDestBearingRef",
":",
"/* Reference for bearing of destination GPSDestBearingRef 23 */",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSDestBearingRef\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_GPS_GPSDestBearing",
":",
"/* Bearing of destination GPSDestBearing 24 */",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSDestBearing\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_GPS_GPSDestDistanceRef",
":",
"/* Reference for distance to destination GPSDestDistanceRef 25 */",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSDestDistanceRef\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_GPS_GPSDestDistance",
":",
"/* Distance to destination GPSDestDistance 26 */",
"//$this->ImageInfo['h'][\"GPSDestDistance\"] = $this->ConvertAnyFormat($ValuePtr, $Format);",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSDestDistance\"",
"]",
"=",
"sprintf",
"(",
"\"%4.2f (%d/%d)\"",
",",
"(",
"double",
")",
"$",
"tmp",
"[",
"0",
"]",
",",
"$",
"tmp",
"[",
"1",
"]",
"[",
"0",
"]",
",",
"$",
"tmp",
"[",
"1",
"]",
"[",
"1",
"]",
")",
";",
";",
"break",
";",
"case",
"TAG_GPS_GPSProcessingMethod",
":",
"/* Name of GPS processing method GPSProcessingMethod 27 */",
"//$this->ImageInfo['h'][\"GPSProcessingMethod\"] = $this->ConvertAnyFormat($ValuePtr, $Format);",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSProcessingMethod\"",
"]",
"=",
"sprintf",
"(",
"\"%4.2f (%d/%d)\"",
",",
"(",
"double",
")",
"$",
"tmp",
"[",
"0",
"]",
",",
"$",
"tmp",
"[",
"1",
"]",
"[",
"0",
"]",
",",
"$",
"tmp",
"[",
"1",
"]",
"[",
"1",
"]",
")",
";",
";",
"break",
";",
"case",
"TAG_GPS_GPSAreaInformation",
":",
"/* Name of GPS area GPSAreaInformation 28 */",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSAreaInformation\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_GPS_GPSDateStamp",
":",
"/* GPS date GPSDateStamp 29 */",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSDateStamp\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_GPS_GPSDifferential",
":",
"/* GPS differential correction GPSDifferential 30 */",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"GPSDifferential\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_AUDIO_MU_LAW",
":",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"AudioMuLaw\"",
"]",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"break",
";",
"case",
"TAG_AUDIO_IMA_ADPCM_DESC",
":",
"// IMA-ADPCM Audio File Description Example - 40",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"AudioIMA-ADPCM-DESC\"",
"]",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"break",
";",
"case",
"TAG_AUDIO_MU_LAW_DESC",
":",
"// µ-Law Audio File Description Sample - 50",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"AudioMuLawDesc\"",
"]",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"break",
";",
"case",
"TAG_EXPOSURE_INDEX",
":",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"ExposureIndex\"",
"]",
"=",
"sprintf",
"(",
"\"%4.2f (%d/%d)\"",
",",
"(",
"double",
")",
"$",
"tmp",
"[",
"0",
"]",
",",
"$",
"tmp",
"[",
"1",
"]",
"[",
"0",
"]",
",",
"$",
"tmp",
"[",
"1",
"]",
"[",
"1",
"]",
")",
";",
";",
"break",
";",
"case",
"TAG_SENSING_METHOD",
":",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"tmpArr",
"=",
"array",
"(",
"\"1\"",
"=>",
"\"Not Defined\"",
",",
"\"2\"",
"=>",
"\"One-chip color area sensor\"",
",",
"\"3\"",
"=>",
"\"Two-chip color area sensor\"",
",",
"\"4\"",
"=>",
"\"Three -chip color area sensor\"",
",",
"\"5\"",
"=>",
"\"Color sequential area sensor\"",
",",
"\"6\"",
"=>",
"\"Trilinear sensor\"",
",",
"\"7\"",
"=>",
"\"Color sequential linear sensor\"",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"sensing\"",
"]",
"=",
"(",
"isset",
"(",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
")",
"?",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
":",
"\"Reserved\"",
")",
";",
"break",
";",
"case",
"TAG_SOUCE_TYPE",
":",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"sourceType\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_SCENE_TYPE",
":",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"sceneType\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_CFA_PATTERN",
":",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"CFAPattern\"",
"]",
"=",
"$",
"this",
"->",
"string_format",
"(",
"substr",
"(",
"$",
"ValuePtr",
",",
"0",
",",
"$",
"ByteCount",
")",
")",
";",
"break",
";",
"case",
"TAG_CUSTOM_RENDERED",
":",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"customRendered\"",
"]",
"=",
"(",
"$",
"tmp",
"==",
"0",
")",
"?",
"'Normal Process'",
":",
"(",
"$",
"tmp",
"==",
"1",
"?",
"'Custom Process'",
":",
"'Reserved'",
")",
";",
"break",
";",
"case",
"TAG_EXPOSURE_MODE",
":",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"tmpArr",
"=",
"array",
"(",
"'Auto Exposure'",
",",
"'Manual Exposure'",
",",
"'Auto Bracket'",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"exposureMode\"",
"]",
"=",
"(",
"isset",
"(",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
")",
"?",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
":",
"\"Reserved\"",
")",
";",
"break",
";",
"case",
"TAG_WHITE_BALANCE",
":",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"whiteBalance\"",
"]",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"break",
";",
"case",
"TAG_DIGITAL_ZOOM_RATIO",
":",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"zoomRatio\"",
"]",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"zoomRatio\"",
"]",
"=",
"sprintf",
"(",
"\"%4.2f (%d/%d)\"",
",",
"(",
"double",
")",
"$",
"tmp",
"[",
"0",
"]",
",",
"$",
"tmp",
"[",
"1",
"]",
"[",
"0",
"]",
",",
"$",
"tmp",
"[",
"1",
"]",
"[",
"1",
"]",
")",
";",
"break",
";",
"case",
"TAG_FLENGTH_IN35MM",
":",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"flength35mm\"",
"]",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"break",
";",
"case",
"TAG_SCREEN_CAP_TYPE",
":",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"tmpArr",
"=",
"array",
"(",
"\"Standard\"",
",",
"\"Landscape\"",
",",
"\"Portrait\"",
",",
"\"Night Scene\"",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"screenCaptureType\"",
"]",
"=",
"(",
"isset",
"(",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
")",
"?",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
":",
"\"Reserved\"",
")",
";",
"break",
";",
"case",
"TAG_GAIN_CONTROL",
":",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"tmpArr",
"=",
"array",
"(",
"\"None\"",
",",
"\"Low Gain Up\"",
",",
"\"High Gain Up\"",
",",
"\"Low Gain Down\"",
",",
"\"High Gain Down\"",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"gainControl\"",
"]",
"=",
"(",
"isset",
"(",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
")",
"?",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
":",
"\"Reserved\"",
")",
";",
"break",
";",
"case",
"TAG_CONTRAST",
":",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"tmpArr",
"=",
"array",
"(",
"\"Normal\"",
",",
"\"Soft\"",
",",
"\"Hard\"",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"contrast\"",
"]",
"=",
"(",
"isset",
"(",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
")",
"?",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
":",
"\"Reserved\"",
")",
";",
"break",
";",
"case",
"TAG_SATURATION",
":",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"tmpArr",
"=",
"array",
"(",
"\"Normal\"",
",",
"\"Low Saturation\"",
",",
"\"High Saturation\"",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"saturation\"",
"]",
"=",
"(",
"isset",
"(",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
")",
"?",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
":",
"\"Reserved\"",
")",
";",
"break",
";",
"case",
"TAG_SHARPNESS",
":",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"tmpArr",
"=",
"array",
"(",
"\"Normal\"",
",",
"\"Soft\"",
",",
"\"Hard\"",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"sharpness\"",
"]",
"=",
"(",
"isset",
"(",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
")",
"?",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
":",
"\"Reserved\"",
")",
";",
"break",
";",
"case",
"TAG_DIST_RANGE",
":",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"tmpArr",
"=",
"array",
"(",
"\"Unknown\"",
",",
"\"Macro\"",
",",
"\"Close View\"",
",",
"\"Distant View\"",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"distanceRange\"",
"]",
"=",
"(",
"isset",
"(",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
")",
"?",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
":",
"\"Reserved\"",
")",
";",
"break",
";",
"case",
"TAG_DEVICE_SETTING_DESC",
":",
"/*\n $tmp = $this->ConvertAnyFormat($ValuePtr, $Format);\n $tmpArr = array(\"Unknown\",\"Macro\",\"Close View\",\"Distant View\");\n $this->ImageInfo['h'][\"distanceRange\"] =\n (isset($tmpArr[\"$tmp\"]) ? $tmpArr[\"$tmp\"] : \"Reserved\");\n */",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"deviceSettingDesc\"",
"]",
"=",
"\"NOT IMPLEMENTED\"",
";",
"break",
";",
"case",
"TAG_COMPRESS_SCHEME",
":",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"tmpArr",
"=",
"array",
"(",
"\"1\"",
"=>",
"\"Uncompressed\"",
",",
"\"6\"",
"=>",
"\"JPEG compression (thumbnails only)\"",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"compressScheme\"",
"]",
"=",
"(",
"isset",
"(",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
")",
"?",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
":",
"\"Reserved\"",
")",
";",
"break",
";",
"case",
"TAG_IMAGE_WD",
":",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"jpegImageWidth\"",
"]",
"=",
"$",
"tmp",
";",
"break",
";",
"case",
"TAG_IMAGE_HT",
":",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"jpegImageHeight\"",
"]",
"=",
"$",
"tmp",
";",
"break",
";",
"case",
"TAG_IMAGE_BPS",
":",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"jpegBitsPerSample\"",
"]",
"=",
"$",
"tmp",
";",
"break",
";",
"case",
"TAG_IMAGE_PHOTO_INT",
":",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"jpegPhotometricInt\"",
"]",
"=",
"$",
"tmp",
";",
"$",
"tmpArr",
"=",
"array",
"(",
"\"2\"",
"=>",
"\"RGB\"",
",",
"\"6\"",
"=>",
"\"YCbCr\"",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"jpegPhotometricInt\"",
"]",
"=",
"(",
"isset",
"(",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
")",
"?",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
":",
"\"Reserved\"",
")",
";",
"break",
";",
"case",
"TAG_IMAGE_SOFFSET",
":",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"jpegStripOffsets\"",
"]",
"=",
"$",
"tmp",
";",
"break",
";",
"case",
"TAG_IMAGE_SPP",
":",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"jpegSamplesPerPixel\"",
"]",
"=",
"$",
"tmp",
";",
"break",
";",
"case",
"TAG_IMAGE_RPS",
":",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"jpegRowsPerStrip\"",
"]",
"=",
"$",
"tmp",
";",
"break",
";",
"case",
"TAG_IMAGE_SBC",
":",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"jpegStripByteCounts\"",
"]",
"=",
"$",
"tmp",
";",
"break",
";",
"case",
"TAG_IMAGE_P_CONFIG",
":",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"tmpArr",
"=",
"array",
"(",
"\"1\"",
"=>",
"\"Chunky Format\"",
",",
"\"2\"",
"=>",
"\"Planar Format\"",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"jpegPlanarConfig\"",
"]",
"=",
"(",
"isset",
"(",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
")",
"?",
"$",
"tmpArr",
"[",
"\"$tmp\"",
"]",
":",
"\"Reserved\"",
")",
";",
"break",
";",
"case",
"TAG_FOCALPLANE_YRESOL",
":",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"focalPlaneYResolution\"",
"]",
"=",
"sprintf",
"(",
"\"%4.2f (%d/%d)\"",
",",
"(",
"double",
")",
"$",
"tmp",
"[",
"0",
"]",
",",
"$",
"tmp",
"[",
"1",
"]",
"[",
"0",
"]",
",",
"$",
"tmp",
"[",
"1",
"]",
"[",
"1",
"]",
")",
";",
"break",
";",
"case",
"TAG_BRIGHTNESS",
":",
"$",
"tmp",
"=",
"$",
"this",
"->",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
";",
"$",
"this",
"->",
"ImageInfo",
"[",
"'h'",
"]",
"[",
"\"brightness\"",
"]",
"=",
"sprintf",
"(",
"\"%4.2f (%d/%d)\"",
",",
"(",
"double",
")",
"$",
"tmp",
"[",
"0",
"]",
",",
"$",
"tmp",
"[",
"1",
"]",
"[",
"0",
"]",
",",
"$",
"tmp",
"[",
"1",
"]",
"[",
"1",
"]",
")",
";",
"break",
";",
"//---------------------------------------------",
"case",
"TAG_EXIF_OFFSET",
":",
"case",
"TAG_INTEROP_OFFSET",
":",
"{",
"$",
"SubdirStart",
"=",
"substr",
"(",
"$",
"OffsetBase",
",",
"$",
"this",
"->",
"Get32u",
"(",
"$",
"ValuePtr",
"[",
"0",
"]",
",",
"$",
"ValuePtr",
"[",
"1",
"]",
",",
"$",
"ValuePtr",
"[",
"2",
"]",
",",
"$",
"ValuePtr",
"[",
"3",
"]",
")",
")",
";",
"//if ($SubdirStart < $OffsetBase || $SubdirStart > $OffsetBase+$ExifLength){",
"// debug(\"Illegal exif or interop ofset directory link\",1);",
"//}else{",
"//echo \"<h1>Calling sub-exif dir</h1>\";",
"$",
"this",
"->",
"ProcessExifDir",
"(",
"$",
"SubdirStart",
",",
"$",
"OffsetBase",
",",
"$",
"ExifLength",
")",
";",
"//}",
"continue",
";",
"}",
"default",
":",
"{",
"$",
"this",
"->",
"debug",
"(",
"\"UNKNOWN TAG: $Tag\"",
")",
";",
"}",
"}",
"}",
"{",
"// In addition to linking to subdirectories via exif tags,",
"// there's also a potential link to another directory at the end of each",
"// directory. this has got to be the result of a comitee!",
"$",
"tmpDirStart",
"=",
"substr",
"(",
"$",
"DirStart",
",",
"2",
"+",
"12",
"*",
"$",
"NumDirEntries",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"tmpDirStart",
")",
"+",
"4",
"<=",
"strlen",
"(",
"$",
"OffsetBase",
")",
"+",
"$",
"ExifLength",
")",
"{",
"$",
"Offset",
"=",
"$",
"this",
"->",
"Get32u",
"(",
"$",
"tmpDirStart",
"[",
"0",
"]",
",",
"$",
"tmpDirStart",
"[",
"1",
"]",
",",
"$",
"tmpDirStart",
"[",
"2",
"]",
",",
"$",
"tmpDirStart",
"[",
"3",
"]",
")",
";",
"if",
"(",
"$",
"Offset",
")",
"{",
"$",
"SubdirStart",
"=",
"substr",
"(",
"$",
"OffsetBase",
",",
"$",
"Offset",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"SubdirStart",
")",
">",
"strlen",
"(",
"$",
"OffsetBase",
")",
"+",
"$",
"ExifLength",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"SubdirStart",
")",
"<",
"strlen",
"(",
"$",
"OffsetBase",
")",
"+",
"$",
"ExifLength",
"+",
"20",
")",
"{",
"// Jhead 1.3 or earlier would crop the whole directory!",
"// As Jhead produces this form of format incorrectness,",
"// I'll just let it pass silently",
"}",
"else",
"{",
"$",
"this",
"->",
"errno",
"=",
"51",
";",
"$",
"this",
"->",
"errstr",
"=",
"\"Illegal subdirectory link\"",
";",
"$",
"this",
"->",
"debug",
"(",
"$",
"this",
"->",
"errstr",
",",
"1",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"strlen",
"(",
"$",
"SubdirStart",
")",
"<=",
"strlen",
"(",
"$",
"OffsetBase",
")",
"+",
"$",
"ExifLength",
")",
"{",
"$",
"this",
"->",
"ProcessExifDir",
"(",
"$",
"SubdirStart",
",",
"$",
"OffsetBase",
",",
"$",
"ExifLength",
")",
";",
"}",
"}",
"}",
"}",
"else",
"{",
"// The exif header ends before the last next directory pointer.",
"}",
"}",
"/**\n * Check if thumbnail has been cached or not.\n * If yes! then read the file.\n */",
"/*\n if(file_exists($this->thumbnail) && $this->caching && (filemtime($this->thumbnail) == filemtime($this->file) )) {\n $this->ImageInfo[\"h\"][\"Thumbnail\"] = $this->thumbnail;\n $this->ImageInfo[\"h\"][\"ThumbnailSize\"] = sprintf(\"%d bytes\",filesize($this->thumbnail));\n } else{\n if ($this->ThumbnailSize && $this->ThumbnailOffset){\n if ($this->ThumbnailSize + $this->ThumbnailOffset <= $ExifLength){\n // The thumbnail pointer appears to be valid. Store it.\n $this->ImageInfo[\"h\"][\"Thumbnail\"] = substr($OffsetBase,$this->ThumbnailOffset);\n\n // Save the thumbnail /\n if($this->caching && is_dir($this->cacheDir)) {\n $this->saveThumbnail($this->thumbnail);\n $this->ImageInfo[\"h\"][\"Thumbnail\"] = $this->thumbnail;\n }\n $this->ImageInfo[\"h\"][\"ThumbnailSize\"] = sprintf(\"%d bytes\",strlen($this->ImageInfo[\"h\"][\"Thumbnail\"]));\n }\n }\n }\n */",
"}"
] | Process one of the nested EXIF directories.
@param string $DirStart All directory information
@param string $OffsetBase whole Section
@param int $ExifLength Length of exif section | [
"Process",
"one",
"of",
"the",
"nested",
"EXIF",
"directories",
".",
"@param",
"string",
"$DirStart",
"All",
"directory",
"information",
"@param",
"string",
"$OffsetBase",
"whole",
"Section",
"@param",
"int",
"$ExifLength",
"Length",
"of",
"exif",
"section"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/exifReader.php#L768-L1559 |
Eresus/EresusCMS | src/ext-3rd/tinymce/plugins/images/connector/php/exifReader.php | phpExifReader.process_EXIF | function process_EXIF($data, $length)
{
$this->debug("Exif header $length bytes long\n");
if (($data[2] . $data[3] . $data[4] . $data[5]) != "Exif")
{
$this->errno = 52;
$this->errstr = "NOT EXIF FORMAT";
$this->debug($this->errstr, 1);
}
$this->ImageInfo["h"]["FlashUsed"] = 0;
/** If it s from a digicam, and it used flash, it says so. */
$this->FocalplaneXRes = 0;
$this->FocalplaneUnits = 0;
$this->ExifImageWidth = 0;
if (($data[8] . $data[9]) == "II")
{
$this->debug("Exif section in Intel order\n");
$this->MotorolaOrder = 0;
}
else
{
if (($data[8] . $data[9]) == "MM")
{
$this->debug("Exif section in Motorola order\n");
$this->MotorolaOrder = 1;
}
else
{
$this->errno = 53;
$this->errstr = "Invalid Exif alignment marker.\n";
$this->debug($this->errstr, 1);
return;
}
}
if ($this->Get16u($data[10], $data[11]) != 0x2A || $this->Get32s($data[12], $data[13], $data[14], $data[15]) != 0x08)
{
$this->errno = 54;
$this->errstr = "Invalid Exif start (1)";
$this->debug($this->errstr, 1);
}
$DirWithThumbnailPtrs = NULL;
//$this->ProcessExifDir(array_slice($data,16),array_slice($data,8),$length);
$this->ProcessExifDir(substr($data, 16), substr($data, 8), $length);
// Compute the CCD width, in milimeters. 2
if ($this->FocalplaneXRes != 0)
{
$this->ImageInfo["h"]["CCDWidth"] = sprintf("%4.2fmm", (float)($this->ExifImageWidth * $this->FocalplaneUnits / $this->FocalplaneXRes));
}
$this->debug("Non settings part of Exif header: " . $length . " bytes\n");
} | php | function process_EXIF($data, $length)
{
$this->debug("Exif header $length bytes long\n");
if (($data[2] . $data[3] . $data[4] . $data[5]) != "Exif")
{
$this->errno = 52;
$this->errstr = "NOT EXIF FORMAT";
$this->debug($this->errstr, 1);
}
$this->ImageInfo["h"]["FlashUsed"] = 0;
/** If it s from a digicam, and it used flash, it says so. */
$this->FocalplaneXRes = 0;
$this->FocalplaneUnits = 0;
$this->ExifImageWidth = 0;
if (($data[8] . $data[9]) == "II")
{
$this->debug("Exif section in Intel order\n");
$this->MotorolaOrder = 0;
}
else
{
if (($data[8] . $data[9]) == "MM")
{
$this->debug("Exif section in Motorola order\n");
$this->MotorolaOrder = 1;
}
else
{
$this->errno = 53;
$this->errstr = "Invalid Exif alignment marker.\n";
$this->debug($this->errstr, 1);
return;
}
}
if ($this->Get16u($data[10], $data[11]) != 0x2A || $this->Get32s($data[12], $data[13], $data[14], $data[15]) != 0x08)
{
$this->errno = 54;
$this->errstr = "Invalid Exif start (1)";
$this->debug($this->errstr, 1);
}
$DirWithThumbnailPtrs = NULL;
//$this->ProcessExifDir(array_slice($data,16),array_slice($data,8),$length);
$this->ProcessExifDir(substr($data, 16), substr($data, 8), $length);
// Compute the CCD width, in milimeters. 2
if ($this->FocalplaneXRes != 0)
{
$this->ImageInfo["h"]["CCDWidth"] = sprintf("%4.2fmm", (float)($this->ExifImageWidth * $this->FocalplaneUnits / $this->FocalplaneXRes));
}
$this->debug("Non settings part of Exif header: " . $length . " bytes\n");
} | [
"function",
"process_EXIF",
"(",
"$",
"data",
",",
"$",
"length",
")",
"{",
"$",
"this",
"->",
"debug",
"(",
"\"Exif header $length bytes long\\n\"",
")",
";",
"if",
"(",
"(",
"$",
"data",
"[",
"2",
"]",
".",
"$",
"data",
"[",
"3",
"]",
".",
"$",
"data",
"[",
"4",
"]",
".",
"$",
"data",
"[",
"5",
"]",
")",
"!=",
"\"Exif\"",
")",
"{",
"$",
"this",
"->",
"errno",
"=",
"52",
";",
"$",
"this",
"->",
"errstr",
"=",
"\"NOT EXIF FORMAT\"",
";",
"$",
"this",
"->",
"debug",
"(",
"$",
"this",
"->",
"errstr",
",",
"1",
")",
";",
"}",
"$",
"this",
"->",
"ImageInfo",
"[",
"\"h\"",
"]",
"[",
"\"FlashUsed\"",
"]",
"=",
"0",
";",
"/** If it s from a digicam, and it used flash, it says so. */",
"$",
"this",
"->",
"FocalplaneXRes",
"=",
"0",
";",
"$",
"this",
"->",
"FocalplaneUnits",
"=",
"0",
";",
"$",
"this",
"->",
"ExifImageWidth",
"=",
"0",
";",
"if",
"(",
"(",
"$",
"data",
"[",
"8",
"]",
".",
"$",
"data",
"[",
"9",
"]",
")",
"==",
"\"II\"",
")",
"{",
"$",
"this",
"->",
"debug",
"(",
"\"Exif section in Intel order\\n\"",
")",
";",
"$",
"this",
"->",
"MotorolaOrder",
"=",
"0",
";",
"}",
"else",
"{",
"if",
"(",
"(",
"$",
"data",
"[",
"8",
"]",
".",
"$",
"data",
"[",
"9",
"]",
")",
"==",
"\"MM\"",
")",
"{",
"$",
"this",
"->",
"debug",
"(",
"\"Exif section in Motorola order\\n\"",
")",
";",
"$",
"this",
"->",
"MotorolaOrder",
"=",
"1",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"errno",
"=",
"53",
";",
"$",
"this",
"->",
"errstr",
"=",
"\"Invalid Exif alignment marker.\\n\"",
";",
"$",
"this",
"->",
"debug",
"(",
"$",
"this",
"->",
"errstr",
",",
"1",
")",
";",
"return",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"Get16u",
"(",
"$",
"data",
"[",
"10",
"]",
",",
"$",
"data",
"[",
"11",
"]",
")",
"!=",
"0x2A",
"||",
"$",
"this",
"->",
"Get32s",
"(",
"$",
"data",
"[",
"12",
"]",
",",
"$",
"data",
"[",
"13",
"]",
",",
"$",
"data",
"[",
"14",
"]",
",",
"$",
"data",
"[",
"15",
"]",
")",
"!=",
"0x08",
")",
"{",
"$",
"this",
"->",
"errno",
"=",
"54",
";",
"$",
"this",
"->",
"errstr",
"=",
"\"Invalid Exif start (1)\"",
";",
"$",
"this",
"->",
"debug",
"(",
"$",
"this",
"->",
"errstr",
",",
"1",
")",
";",
"}",
"$",
"DirWithThumbnailPtrs",
"=",
"NULL",
";",
"//$this->ProcessExifDir(array_slice($data,16),array_slice($data,8),$length);",
"$",
"this",
"->",
"ProcessExifDir",
"(",
"substr",
"(",
"$",
"data",
",",
"16",
")",
",",
"substr",
"(",
"$",
"data",
",",
"8",
")",
",",
"$",
"length",
")",
";",
"// Compute the CCD width, in milimeters. 2",
"if",
"(",
"$",
"this",
"->",
"FocalplaneXRes",
"!=",
"0",
")",
"{",
"$",
"this",
"->",
"ImageInfo",
"[",
"\"h\"",
"]",
"[",
"\"CCDWidth\"",
"]",
"=",
"sprintf",
"(",
"\"%4.2fmm\"",
",",
"(",
"float",
")",
"(",
"$",
"this",
"->",
"ExifImageWidth",
"*",
"$",
"this",
"->",
"FocalplaneUnits",
"/",
"$",
"this",
"->",
"FocalplaneXRes",
")",
")",
";",
"}",
"$",
"this",
"->",
"debug",
"(",
"\"Non settings part of Exif header: \"",
".",
"$",
"length",
".",
"\" bytes\\n\"",
")",
";",
"}"
] | Process Exif data
@param array $data Section data as an array
@param int $length Length of the section (length of data array) | [
"Process",
"Exif",
"data",
"@param",
"array",
"$data",
"Section",
"data",
"as",
"an",
"array",
"@param",
"int",
"$length",
"Length",
"of",
"the",
"section",
"(",
"length",
"of",
"data",
"array",
")"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/exifReader.php#L1578-L1636 |
Eresus/EresusCMS | src/ext-3rd/tinymce/plugins/images/connector/php/exifReader.php | phpExifReader.Get16u | function Get16u($val, $by)
{
if ($this->MotorolaOrder)
{
return ((ord($val) << 8) | ord($by));
}
else
{
return ((ord($by) << 8) | ord($val));
}
} | php | function Get16u($val, $by)
{
if ($this->MotorolaOrder)
{
return ((ord($val) << 8) | ord($by));
}
else
{
return ((ord($by) << 8) | ord($val));
}
} | [
"function",
"Get16u",
"(",
"$",
"val",
",",
"$",
"by",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"MotorolaOrder",
")",
"{",
"return",
"(",
"(",
"ord",
"(",
"$",
"val",
")",
"<<",
"8",
")",
"|",
"ord",
"(",
"$",
"by",
")",
")",
";",
"}",
"else",
"{",
"return",
"(",
"(",
"ord",
"(",
"$",
"by",
")",
"<<",
"8",
")",
"|",
"ord",
"(",
"$",
"val",
")",
")",
";",
"}",
"}"
] | Converts two byte number into its equivalent int integer
@param int
@param int | [
"Converts",
"two",
"byte",
"number",
"into",
"its",
"equivalent",
"int",
"integer",
"@param",
"int",
"@param",
"int"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/exifReader.php#L1644-L1654 |
Eresus/EresusCMS | src/ext-3rd/tinymce/plugins/images/connector/php/exifReader.php | phpExifReader.Get32s | function Get32s($val1, $val2, $val3, $val4)
{
$val1 = ord($val1);
$val2 = ord($val2);
$val3 = ord($val3);
$val4 = ord($val4);
if ($this->MotorolaOrder)
{
return (($val1 << 24) | ($val2 << 16) | ($val3 << 8) | ($val4 << 0));
}
else
{
return (($val4 << 24) | ($val3 << 16) | ($val2 << 8) | ($val1 << 0));
}
} | php | function Get32s($val1, $val2, $val3, $val4)
{
$val1 = ord($val1);
$val2 = ord($val2);
$val3 = ord($val3);
$val4 = ord($val4);
if ($this->MotorolaOrder)
{
return (($val1 << 24) | ($val2 << 16) | ($val3 << 8) | ($val4 << 0));
}
else
{
return (($val4 << 24) | ($val3 << 16) | ($val2 << 8) | ($val1 << 0));
}
} | [
"function",
"Get32s",
"(",
"$",
"val1",
",",
"$",
"val2",
",",
"$",
"val3",
",",
"$",
"val4",
")",
"{",
"$",
"val1",
"=",
"ord",
"(",
"$",
"val1",
")",
";",
"$",
"val2",
"=",
"ord",
"(",
"$",
"val2",
")",
";",
"$",
"val3",
"=",
"ord",
"(",
"$",
"val3",
")",
";",
"$",
"val4",
"=",
"ord",
"(",
"$",
"val4",
")",
";",
"if",
"(",
"$",
"this",
"->",
"MotorolaOrder",
")",
"{",
"return",
"(",
"(",
"$",
"val1",
"<<",
"24",
")",
"|",
"(",
"$",
"val2",
"<<",
"16",
")",
"|",
"(",
"$",
"val3",
"<<",
"8",
")",
"|",
"(",
"$",
"val4",
"<<",
"0",
")",
")",
";",
"}",
"else",
"{",
"return",
"(",
"(",
"$",
"val4",
"<<",
"24",
")",
"|",
"(",
"$",
"val3",
"<<",
"16",
")",
"|",
"(",
"$",
"val2",
"<<",
"8",
")",
"|",
"(",
"$",
"val1",
"<<",
"0",
")",
")",
";",
"}",
"}"
] | Converts 4-byte number into its equivalent integer
@param int
@param int
@param int
@param int
@return int | [
"Converts",
"4",
"-",
"byte",
"number",
"into",
"its",
"equivalent",
"integer"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/exifReader.php#L1666-L1681 |
Eresus/EresusCMS | src/ext-3rd/tinymce/plugins/images/connector/php/exifReader.php | phpExifReader.get32u | function get32u($val1, $val2, $val3, $val4)
{
return ($this->Get32s($val1, $val2, $val3, $val4) & 0xffffffff);
} | php | function get32u($val1, $val2, $val3, $val4)
{
return ($this->Get32s($val1, $val2, $val3, $val4) & 0xffffffff);
} | [
"function",
"get32u",
"(",
"$",
"val1",
",",
"$",
"val2",
",",
"$",
"val3",
",",
"$",
"val4",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"Get32s",
"(",
"$",
"val1",
",",
"$",
"val2",
",",
"$",
"val3",
",",
"$",
"val4",
")",
"&",
"0xffffffff",
")",
";",
"}"
] | Converts 4-byte number into its equivalent integer with the help of Get32s
@param int
@param int
@param int
@param int
@return int | [
"Converts",
"4",
"-",
"byte",
"number",
"into",
"its",
"equivalent",
"integer",
"with",
"the",
"help",
"of",
"Get32s"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/exifReader.php#L1694-L1697 |
Eresus/EresusCMS | src/ext-3rd/tinymce/plugins/images/connector/php/exifReader.php | phpExifReader.ConvertAnyFormat | function ConvertAnyFormat($ValuePtr, $Format)
{
$Value = 0;
switch ($Format)
{
case FMT_SBYTE:
$Value = $ValuePtr[0];
break;
case FMT_BYTE:
$Value = $ValuePtr[0];
break;
case FMT_USHORT:
$Value = $this->Get16u($ValuePtr[0], $ValuePtr[1]);
break;
case FMT_ULONG:
$Value = $this->Get32u($ValuePtr[0], $ValuePtr[1], $ValuePtr[2], $ValuePtr[3]);
break;
case FMT_URATIONAL:
case FMT_SRATIONAL:
{
$Num = $this->Get32s($ValuePtr[0], $ValuePtr[1], $ValuePtr[2], $ValuePtr[3]);
$Den = $this->Get32s($ValuePtr[4], $ValuePtr[5], $ValuePtr[6], $ValuePtr[7]);
if ($Den == 0)
{
$Value = 0;
}
else
{
$Value = (double)($Num / $Den);
}
return array($Value, array($Num, $Den));
break;
}
case FMT_SSHORT:
$Value = $this->Get16u($ValuePtr[0], $ValuePtr[1]);
break;
case FMT_SLONG:
$Value = $this->Get32s($ValuePtr[0], $ValuePtr[1], $ValuePtr[2], $ValuePtr[3]);
break;
// Not sure if this is correct (never seen float used in Exif format)
case FMT_SINGLE:
$Value = $ValuePtr[0];
break;
case FMT_DOUBLE:
$Value = $ValuePtr[0];
break;
}
return $Value;
} | php | function ConvertAnyFormat($ValuePtr, $Format)
{
$Value = 0;
switch ($Format)
{
case FMT_SBYTE:
$Value = $ValuePtr[0];
break;
case FMT_BYTE:
$Value = $ValuePtr[0];
break;
case FMT_USHORT:
$Value = $this->Get16u($ValuePtr[0], $ValuePtr[1]);
break;
case FMT_ULONG:
$Value = $this->Get32u($ValuePtr[0], $ValuePtr[1], $ValuePtr[2], $ValuePtr[3]);
break;
case FMT_URATIONAL:
case FMT_SRATIONAL:
{
$Num = $this->Get32s($ValuePtr[0], $ValuePtr[1], $ValuePtr[2], $ValuePtr[3]);
$Den = $this->Get32s($ValuePtr[4], $ValuePtr[5], $ValuePtr[6], $ValuePtr[7]);
if ($Den == 0)
{
$Value = 0;
}
else
{
$Value = (double)($Num / $Den);
}
return array($Value, array($Num, $Den));
break;
}
case FMT_SSHORT:
$Value = $this->Get16u($ValuePtr[0], $ValuePtr[1]);
break;
case FMT_SLONG:
$Value = $this->Get32s($ValuePtr[0], $ValuePtr[1], $ValuePtr[2], $ValuePtr[3]);
break;
// Not sure if this is correct (never seen float used in Exif format)
case FMT_SINGLE:
$Value = $ValuePtr[0];
break;
case FMT_DOUBLE:
$Value = $ValuePtr[0];
break;
}
return $Value;
} | [
"function",
"ConvertAnyFormat",
"(",
"$",
"ValuePtr",
",",
"$",
"Format",
")",
"{",
"$",
"Value",
"=",
"0",
";",
"switch",
"(",
"$",
"Format",
")",
"{",
"case",
"FMT_SBYTE",
":",
"$",
"Value",
"=",
"$",
"ValuePtr",
"[",
"0",
"]",
";",
"break",
";",
"case",
"FMT_BYTE",
":",
"$",
"Value",
"=",
"$",
"ValuePtr",
"[",
"0",
"]",
";",
"break",
";",
"case",
"FMT_USHORT",
":",
"$",
"Value",
"=",
"$",
"this",
"->",
"Get16u",
"(",
"$",
"ValuePtr",
"[",
"0",
"]",
",",
"$",
"ValuePtr",
"[",
"1",
"]",
")",
";",
"break",
";",
"case",
"FMT_ULONG",
":",
"$",
"Value",
"=",
"$",
"this",
"->",
"Get32u",
"(",
"$",
"ValuePtr",
"[",
"0",
"]",
",",
"$",
"ValuePtr",
"[",
"1",
"]",
",",
"$",
"ValuePtr",
"[",
"2",
"]",
",",
"$",
"ValuePtr",
"[",
"3",
"]",
")",
";",
"break",
";",
"case",
"FMT_URATIONAL",
":",
"case",
"FMT_SRATIONAL",
":",
"{",
"$",
"Num",
"=",
"$",
"this",
"->",
"Get32s",
"(",
"$",
"ValuePtr",
"[",
"0",
"]",
",",
"$",
"ValuePtr",
"[",
"1",
"]",
",",
"$",
"ValuePtr",
"[",
"2",
"]",
",",
"$",
"ValuePtr",
"[",
"3",
"]",
")",
";",
"$",
"Den",
"=",
"$",
"this",
"->",
"Get32s",
"(",
"$",
"ValuePtr",
"[",
"4",
"]",
",",
"$",
"ValuePtr",
"[",
"5",
"]",
",",
"$",
"ValuePtr",
"[",
"6",
"]",
",",
"$",
"ValuePtr",
"[",
"7",
"]",
")",
";",
"if",
"(",
"$",
"Den",
"==",
"0",
")",
"{",
"$",
"Value",
"=",
"0",
";",
"}",
"else",
"{",
"$",
"Value",
"=",
"(",
"double",
")",
"(",
"$",
"Num",
"/",
"$",
"Den",
")",
";",
"}",
"return",
"array",
"(",
"$",
"Value",
",",
"array",
"(",
"$",
"Num",
",",
"$",
"Den",
")",
")",
";",
"break",
";",
"}",
"case",
"FMT_SSHORT",
":",
"$",
"Value",
"=",
"$",
"this",
"->",
"Get16u",
"(",
"$",
"ValuePtr",
"[",
"0",
"]",
",",
"$",
"ValuePtr",
"[",
"1",
"]",
")",
";",
"break",
";",
"case",
"FMT_SLONG",
":",
"$",
"Value",
"=",
"$",
"this",
"->",
"Get32s",
"(",
"$",
"ValuePtr",
"[",
"0",
"]",
",",
"$",
"ValuePtr",
"[",
"1",
"]",
",",
"$",
"ValuePtr",
"[",
"2",
"]",
",",
"$",
"ValuePtr",
"[",
"3",
"]",
")",
";",
"break",
";",
"// Not sure if this is correct (never seen float used in Exif format)",
"case",
"FMT_SINGLE",
":",
"$",
"Value",
"=",
"$",
"ValuePtr",
"[",
"0",
"]",
";",
"break",
";",
"case",
"FMT_DOUBLE",
":",
"$",
"Value",
"=",
"$",
"ValuePtr",
"[",
"0",
"]",
";",
"break",
";",
"}",
"return",
"$",
"Value",
";",
"}"
] | -------------------------------------------------------------------------- | [
"--------------------------------------------------------------------------"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/exifReader.php#L1702-L1756 |
Eresus/EresusCMS | src/ext-3rd/tinymce/plugins/images/connector/php/exifReader.php | phpExifReader.saveThumbnail | function saveThumbnail($ThumbFile)
{
$ThumbFile = trim($ThumbFile);
$file = basename($this->file);
if (empty($ThumbFile))
{
$ThumbFile = "th_$file";
}
if (!empty($this->ImageInfo["h"]["Thumbnail"]))
{
$tp = fopen($ThumbFile, "wb");
if (!$tp)
{
$this->errno = 2;
$this->errstr = "Cannot Open file '$ThumbFile'";
}
fwrite($tp, $this->ImageInfo["h"]["Thumbnail"]);
fclose($tp);
touch($ThumbFile, filemtime($this->file));
}
//$this->thumbnailURL = $ThumbFile;
$this->ImageInfo["h"]["Thumbnail"] = $ThumbFile;
} | php | function saveThumbnail($ThumbFile)
{
$ThumbFile = trim($ThumbFile);
$file = basename($this->file);
if (empty($ThumbFile))
{
$ThumbFile = "th_$file";
}
if (!empty($this->ImageInfo["h"]["Thumbnail"]))
{
$tp = fopen($ThumbFile, "wb");
if (!$tp)
{
$this->errno = 2;
$this->errstr = "Cannot Open file '$ThumbFile'";
}
fwrite($tp, $this->ImageInfo["h"]["Thumbnail"]);
fclose($tp);
touch($ThumbFile, filemtime($this->file));
}
//$this->thumbnailURL = $ThumbFile;
$this->ImageInfo["h"]["Thumbnail"] = $ThumbFile;
} | [
"function",
"saveThumbnail",
"(",
"$",
"ThumbFile",
")",
"{",
"$",
"ThumbFile",
"=",
"trim",
"(",
"$",
"ThumbFile",
")",
";",
"$",
"file",
"=",
"basename",
"(",
"$",
"this",
"->",
"file",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"ThumbFile",
")",
")",
"{",
"$",
"ThumbFile",
"=",
"\"th_$file\"",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"ImageInfo",
"[",
"\"h\"",
"]",
"[",
"\"Thumbnail\"",
"]",
")",
")",
"{",
"$",
"tp",
"=",
"fopen",
"(",
"$",
"ThumbFile",
",",
"\"wb\"",
")",
";",
"if",
"(",
"!",
"$",
"tp",
")",
"{",
"$",
"this",
"->",
"errno",
"=",
"2",
";",
"$",
"this",
"->",
"errstr",
"=",
"\"Cannot Open file '$ThumbFile'\"",
";",
"}",
"fwrite",
"(",
"$",
"tp",
",",
"$",
"this",
"->",
"ImageInfo",
"[",
"\"h\"",
"]",
"[",
"\"Thumbnail\"",
"]",
")",
";",
"fclose",
"(",
"$",
"tp",
")",
";",
"touch",
"(",
"$",
"ThumbFile",
",",
"filemtime",
"(",
"$",
"this",
"->",
"file",
")",
")",
";",
"}",
"//$this->thumbnailURL = $ThumbFile;",
"$",
"this",
"->",
"ImageInfo",
"[",
"\"h\"",
"]",
"[",
"\"Thumbnail\"",
"]",
"=",
"$",
"ThumbFile",
";",
"}"
] | Function to extract thumbnail from Exif data of the image.
and store it in a filename given by $ThumbFile
@param string $ThumbFile Files name to store the thumbnail | [
"Function",
"to",
"extract",
"thumbnail",
"from",
"Exif",
"data",
"of",
"the",
"image",
".",
"and",
"store",
"it",
"in",
"a",
"filename",
"given",
"by",
"$ThumbFile"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/exifReader.php#L1765-L1789 |
mikelgoig/nova-spotify-auth-tool | src/Http/Middleware/Authorize.php | Authorize.handle | public function handle($request, $next)
{
return resolve(SpotifyAuthTool::class)->authorize($request) ? $next($request) : abort(403);
} | php | public function handle($request, $next)
{
return resolve(SpotifyAuthTool::class)->authorize($request) ? $next($request) : abort(403);
} | [
"public",
"function",
"handle",
"(",
"$",
"request",
",",
"$",
"next",
")",
"{",
"return",
"resolve",
"(",
"SpotifyAuthTool",
"::",
"class",
")",
"->",
"authorize",
"(",
"$",
"request",
")",
"?",
"$",
"next",
"(",
"$",
"request",
")",
":",
"abort",
"(",
"403",
")",
";",
"}"
] | Handle the incoming request.
@param \Illuminate\Http\Request $request
@param \Closure $next
@return \Illuminate\Http\Response | [
"Handle",
"the",
"incoming",
"request",
"."
] | train | https://github.com/mikelgoig/nova-spotify-auth-tool/blob/a5351c386206c45f77fe6ae833cdac51f2a030f4/src/Http/Middleware/Authorize.php#L16-L19 |
zhouyl/mellivora | Mellivora/Events/CallQueuedHandler.php | CallQueuedHandler.setJobInstanceIfNecessary | protected function setJobInstanceIfNecessary(Job $job, $instance)
{
if (in_array(InteractsWithQueue::class, class_uses_recursive(get_class($instance)))) {
$instance->setJob($job);
}
return $instance;
} | php | protected function setJobInstanceIfNecessary(Job $job, $instance)
{
if (in_array(InteractsWithQueue::class, class_uses_recursive(get_class($instance)))) {
$instance->setJob($job);
}
return $instance;
} | [
"protected",
"function",
"setJobInstanceIfNecessary",
"(",
"Job",
"$",
"job",
",",
"$",
"instance",
")",
"{",
"if",
"(",
"in_array",
"(",
"InteractsWithQueue",
"::",
"class",
",",
"class_uses_recursive",
"(",
"get_class",
"(",
"$",
"instance",
")",
")",
")",
")",
"{",
"$",
"instance",
"->",
"setJob",
"(",
"$",
"job",
")",
";",
"}",
"return",
"$",
"instance",
";",
"}"
] | Set the job instance of the given class if necessary.
@param \Mellivora\Support\Contracts\Queue\Job $job
@param mixed $instance
@return mixed | [
"Set",
"the",
"job",
"instance",
"of",
"the",
"given",
"class",
"if",
"necessary",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Events/CallQueuedHandler.php#L63-L70 |
zhouyl/mellivora | Mellivora/Events/CallQueuedHandler.php | CallQueuedHandler.failed | public function failed(array $data, $e)
{
$handler = $this->container->make($data['class']);
$parameters = array_merge(unserialize($data['data']), [$e]);
if (method_exists($handler, 'failed')) {
call_user_func_array([$handler, 'failed'], $parameters);
}
} | php | public function failed(array $data, $e)
{
$handler = $this->container->make($data['class']);
$parameters = array_merge(unserialize($data['data']), [$e]);
if (method_exists($handler, 'failed')) {
call_user_func_array([$handler, 'failed'], $parameters);
}
} | [
"public",
"function",
"failed",
"(",
"array",
"$",
"data",
",",
"$",
"e",
")",
"{",
"$",
"handler",
"=",
"$",
"this",
"->",
"container",
"->",
"make",
"(",
"$",
"data",
"[",
"'class'",
"]",
")",
";",
"$",
"parameters",
"=",
"array_merge",
"(",
"unserialize",
"(",
"$",
"data",
"[",
"'data'",
"]",
")",
",",
"[",
"$",
"e",
"]",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"handler",
",",
"'failed'",
")",
")",
"{",
"call_user_func_array",
"(",
"[",
"$",
"handler",
",",
"'failed'",
"]",
",",
"$",
"parameters",
")",
";",
"}",
"}"
] | Call the failed method on the job instance.
The event instance and the exception will be passed.
@param array $data
@param \Exception $e
@return void | [
"Call",
"the",
"failed",
"method",
"on",
"the",
"job",
"instance",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Events/CallQueuedHandler.php#L82-L91 |
WellCommerce/AppBundle | Twig/CurrencyExtension.php | CurrencyExtension.formatPrice | public function formatPrice(float $price, $baseCurrency = null, $targetCurrency = null, $locale = null, $quantity = 1) : string
{
return $this->helper->convertAndFormat($price, $baseCurrency, $targetCurrency, $quantity, $locale);
} | php | public function formatPrice(float $price, $baseCurrency = null, $targetCurrency = null, $locale = null, $quantity = 1) : string
{
return $this->helper->convertAndFormat($price, $baseCurrency, $targetCurrency, $quantity, $locale);
} | [
"public",
"function",
"formatPrice",
"(",
"float",
"$",
"price",
",",
"$",
"baseCurrency",
"=",
"null",
",",
"$",
"targetCurrency",
"=",
"null",
",",
"$",
"locale",
"=",
"null",
",",
"$",
"quantity",
"=",
"1",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"helper",
"->",
"convertAndFormat",
"(",
"$",
"price",
",",
"$",
"baseCurrency",
",",
"$",
"targetCurrency",
",",
"$",
"quantity",
",",
"$",
"locale",
")",
";",
"}"
] | Formats the given amount
@param int|float $price
@param null|string $baseCurrency
@param null|string $targetCurrency
@param null|string $locale
@return string | [
"Formats",
"the",
"given",
"amount"
] | train | https://github.com/WellCommerce/AppBundle/blob/2add687d1c898dd0b24afd611d896e3811a0eac3/Twig/CurrencyExtension.php#L75-L78 |
WellCommerce/AppBundle | Twig/CurrencyExtension.php | CurrencyExtension.convertPrice | public function convertPrice(float $price, $baseCurrency = null, $targetCurrency = null, $quantity = 1) : string
{
return $this->helper->convert($price, $baseCurrency, $targetCurrency, $quantity);
} | php | public function convertPrice(float $price, $baseCurrency = null, $targetCurrency = null, $quantity = 1) : string
{
return $this->helper->convert($price, $baseCurrency, $targetCurrency, $quantity);
} | [
"public",
"function",
"convertPrice",
"(",
"float",
"$",
"price",
",",
"$",
"baseCurrency",
"=",
"null",
",",
"$",
"targetCurrency",
"=",
"null",
",",
"$",
"quantity",
"=",
"1",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"helper",
"->",
"convert",
"(",
"$",
"price",
",",
"$",
"baseCurrency",
",",
"$",
"targetCurrency",
",",
"$",
"quantity",
")",
";",
"}"
] | Converts the given amount
@param float $price
@param null|string $baseCurrency
@param null|string $targetCurrency
@param int $quantity
@return string | [
"Converts",
"the",
"given",
"amount"
] | train | https://github.com/WellCommerce/AppBundle/blob/2add687d1c898dd0b24afd611d896e3811a0eac3/Twig/CurrencyExtension.php#L90-L93 |
tttptd/laravel-responder | src/Transformer.php | Transformer.getRelations | public function getRelations():array
{
$relations = array_unique(array_merge($this->getAvailableIncludes(), $this->relations));
return array_filter($relations, function($relation) {
return $relation !== '*';
});
} | php | public function getRelations():array
{
$relations = array_unique(array_merge($this->getAvailableIncludes(), $this->relations));
return array_filter($relations, function($relation) {
return $relation !== '*';
});
} | [
"public",
"function",
"getRelations",
"(",
")",
":",
"array",
"{",
"$",
"relations",
"=",
"array_unique",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"getAvailableIncludes",
"(",
")",
",",
"$",
"this",
"->",
"relations",
")",
")",
";",
"return",
"array_filter",
"(",
"$",
"relations",
",",
"function",
"(",
"$",
"relation",
")",
"{",
"return",
"$",
"relation",
"!==",
"'*'",
";",
"}",
")",
";",
"}"
] | Get relations set on the transformer.
@return array | [
"Get",
"relations",
"set",
"on",
"the",
"transformer",
"."
] | train | https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/Transformer.php#L32-L39 |
tttptd/laravel-responder | src/Transformer.php | Transformer.setRelations | public function setRelations($relations)
{
$this->setAvailableIncludes(array_unique(array_merge($this->availableIncludes, (array) $relations)));
return $this;
} | php | public function setRelations($relations)
{
$this->setAvailableIncludes(array_unique(array_merge($this->availableIncludes, (array) $relations)));
return $this;
} | [
"public",
"function",
"setRelations",
"(",
"$",
"relations",
")",
"{",
"$",
"this",
"->",
"setAvailableIncludes",
"(",
"array_unique",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"availableIncludes",
",",
"(",
"array",
")",
"$",
"relations",
")",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set relations on the transformer.
@param array|string $relations
@return self | [
"Set",
"relations",
"on",
"the",
"transformer",
"."
] | train | https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/Transformer.php#L47-L52 |
tttptd/laravel-responder | src/Transformer.php | Transformer.callIncludeMethod | protected function callIncludeMethod(Scope $scope, $includeName, $data)
{
if ($includeName === 'pivot') {
return $this->includePivot($data->$includeName);
}
$params = $scope->getManager()->getIncludeParams($scope->getIdentifier($includeName));
if (method_exists($this, $includeName)) {
$include = call_user_func([$this, $includeName], $data, $params);
if ($include instanceof ResourceAbstract) {
return $include;
}
return app(Responder::class)->transform($include)->getResource();
} else {
return app(Responder::class)->transform($data->$includeName)->getResource();
}
} | php | protected function callIncludeMethod(Scope $scope, $includeName, $data)
{
if ($includeName === 'pivot') {
return $this->includePivot($data->$includeName);
}
$params = $scope->getManager()->getIncludeParams($scope->getIdentifier($includeName));
if (method_exists($this, $includeName)) {
$include = call_user_func([$this, $includeName], $data, $params);
if ($include instanceof ResourceAbstract) {
return $include;
}
return app(Responder::class)->transform($include)->getResource();
} else {
return app(Responder::class)->transform($data->$includeName)->getResource();
}
} | [
"protected",
"function",
"callIncludeMethod",
"(",
"Scope",
"$",
"scope",
",",
"$",
"includeName",
",",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"includeName",
"===",
"'pivot'",
")",
"{",
"return",
"$",
"this",
"->",
"includePivot",
"(",
"$",
"data",
"->",
"$",
"includeName",
")",
";",
"}",
"$",
"params",
"=",
"$",
"scope",
"->",
"getManager",
"(",
")",
"->",
"getIncludeParams",
"(",
"$",
"scope",
"->",
"getIdentifier",
"(",
"$",
"includeName",
")",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"includeName",
")",
")",
"{",
"$",
"include",
"=",
"call_user_func",
"(",
"[",
"$",
"this",
",",
"$",
"includeName",
"]",
",",
"$",
"data",
",",
"$",
"params",
")",
";",
"if",
"(",
"$",
"include",
"instanceof",
"ResourceAbstract",
")",
"{",
"return",
"$",
"include",
";",
"}",
"return",
"app",
"(",
"Responder",
"::",
"class",
")",
"->",
"transform",
"(",
"$",
"include",
")",
"->",
"getResource",
"(",
")",
";",
"}",
"else",
"{",
"return",
"app",
"(",
"Responder",
"::",
"class",
")",
"->",
"transform",
"(",
"$",
"data",
"->",
"$",
"includeName",
")",
"->",
"getResource",
"(",
")",
";",
"}",
"}"
] | Call method for retrieving a relation. This method overrides Fractal's own
[callIncludeMethod] method to load relations directly from your models.
@param Scope $scope
@param string $includeName
@param mixed $data
@return \League\Fractal\Resource\ResourceInterface|bool
@throws \Exception | [
"Call",
"method",
"for",
"retrieving",
"a",
"relation",
".",
"This",
"method",
"overrides",
"Fractal",
"s",
"own",
"[",
"callIncludeMethod",
"]",
"method",
"to",
"load",
"relations",
"directly",
"from",
"your",
"models",
"."
] | train | https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/Transformer.php#L74-L93 |
tttptd/laravel-responder | src/Transformer.php | Transformer.includePivot | protected function includePivot(Pivot $pivot)
{
if (! method_exists($this, 'transformPivot')) {
return false;
}
return app(Responder::class)->transform($pivot, function ($pivot) {
return $this->transformPivot($pivot);
})->getResource();
} | php | protected function includePivot(Pivot $pivot)
{
if (! method_exists($this, 'transformPivot')) {
return false;
}
return app(Responder::class)->transform($pivot, function ($pivot) {
return $this->transformPivot($pivot);
})->getResource();
} | [
"protected",
"function",
"includePivot",
"(",
"Pivot",
"$",
"pivot",
")",
"{",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
",",
"'transformPivot'",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"app",
"(",
"Responder",
"::",
"class",
")",
"->",
"transform",
"(",
"$",
"pivot",
",",
"function",
"(",
"$",
"pivot",
")",
"{",
"return",
"$",
"this",
"->",
"transformPivot",
"(",
"$",
"pivot",
")",
";",
"}",
")",
"->",
"getResource",
"(",
")",
";",
"}"
] | Include pivot table data to the response.
@param Pivot $pivot
@return \League\Fractal\Resource\ResourceInterface|bool | [
"Include",
"pivot",
"table",
"data",
"to",
"the",
"response",
"."
] | train | https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/Transformer.php#L101-L110 |
nabab/bbn | src/bbn/cdn/config.php | config._set_cfg | private function _set_cfg(){
if ( \is_array($this->cfg) ){
$p =& $this->cfg['params'];
$components = false;
if ( !empty($p['components']) ){
$components = explode(',', $p['components']);
}
$this->cfg = bbn\x::merge_arrays($this->cfg, [
'test' => !empty($p['test']),
'lang' => empty($p['lang']) ? self::$default_language : $p['lang'],
'nocompil' => !empty($p['nocompil']),
'has_css' => !isset($p['css']) || $p['css'],
'has_dep' => !isset($p['dep']) || $p['dep'],
'latest' => isset($p['latest']) ? 1 : false,
'is_component' => !empty($p['components']),
'components' => $components
]);
}
} | php | private function _set_cfg(){
if ( \is_array($this->cfg) ){
$p =& $this->cfg['params'];
$components = false;
if ( !empty($p['components']) ){
$components = explode(',', $p['components']);
}
$this->cfg = bbn\x::merge_arrays($this->cfg, [
'test' => !empty($p['test']),
'lang' => empty($p['lang']) ? self::$default_language : $p['lang'],
'nocompil' => !empty($p['nocompil']),
'has_css' => !isset($p['css']) || $p['css'],
'has_dep' => !isset($p['dep']) || $p['dep'],
'latest' => isset($p['latest']) ? 1 : false,
'is_component' => !empty($p['components']),
'components' => $components
]);
}
} | [
"private",
"function",
"_set_cfg",
"(",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"this",
"->",
"cfg",
")",
")",
"{",
"$",
"p",
"=",
"&",
"$",
"this",
"->",
"cfg",
"[",
"'params'",
"]",
";",
"$",
"components",
"=",
"false",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"p",
"[",
"'components'",
"]",
")",
")",
"{",
"$",
"components",
"=",
"explode",
"(",
"','",
",",
"$",
"p",
"[",
"'components'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"cfg",
"=",
"bbn",
"\\",
"x",
"::",
"merge_arrays",
"(",
"$",
"this",
"->",
"cfg",
",",
"[",
"'test'",
"=>",
"!",
"empty",
"(",
"$",
"p",
"[",
"'test'",
"]",
")",
",",
"'lang'",
"=>",
"empty",
"(",
"$",
"p",
"[",
"'lang'",
"]",
")",
"?",
"self",
"::",
"$",
"default_language",
":",
"$",
"p",
"[",
"'lang'",
"]",
",",
"'nocompil'",
"=>",
"!",
"empty",
"(",
"$",
"p",
"[",
"'nocompil'",
"]",
")",
",",
"'has_css'",
"=>",
"!",
"isset",
"(",
"$",
"p",
"[",
"'css'",
"]",
")",
"||",
"$",
"p",
"[",
"'css'",
"]",
",",
"'has_dep'",
"=>",
"!",
"isset",
"(",
"$",
"p",
"[",
"'dep'",
"]",
")",
"||",
"$",
"p",
"[",
"'dep'",
"]",
",",
"'latest'",
"=>",
"isset",
"(",
"$",
"p",
"[",
"'latest'",
"]",
")",
"?",
"1",
":",
"false",
",",
"'is_component'",
"=>",
"!",
"empty",
"(",
"$",
"p",
"[",
"'components'",
"]",
")",
",",
"'components'",
"=>",
"$",
"components",
"]",
")",
";",
"}",
"}"
] | Returns an array with all the - default or no - config parameters based on the sent ones | [
"Returns",
"an",
"array",
"with",
"all",
"the",
"-",
"default",
"or",
"no",
"-",
"config",
"parameters",
"based",
"on",
"the",
"sent",
"ones"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/cdn/config.php#L34-L52 |
nabab/bbn | src/bbn/cdn/config.php | config._set_files | protected function _set_files(){
// Shortcuts for files and dir
if ( isset($this->cfg['params']['f']) ){
$this->cfg['params']['files'] = $this->cfg['params']['f'];
unset($this->cfg['params']['f']);
}
if ( isset($this->cfg['params']['d']) ){
$this->cfg['params']['dir'] = $this->cfg['params']['d'];
unset($this->cfg['params']['d']);
}
// File
if ( !empty($this->cfg['ext']) && is_file($this->fpath.$this->cfg['url']) ){
$res = $this->get_file();
}
// Preconfigured
else if ( isset($this->cfg['params']['id']) ){
$res = $this->get_preconfig();
}
// List of files
else if ( isset($this->cfg['params']['files']) && is_dir($this->fpath.$this->cfg['url']) ){
$res = $this->get_files();
}
// Directory content
// Vue component
else if ( isset($this->cfg['params']['dir']) && is_dir($this->fpath.$this->cfg['url']) ){
$res = $this->get_dir();
}
else if ( $this->cfg['is_component'] && is_dir($this->fpath.$this->cfg['url']) ){
//cpStart:
$res = [];
$this->cfg['num'] = 0;
foreach ( $this->cfg['components'] as $i => $cp ){
if ( !isset($res[$cp]) ){
$res[$cp] = $this->get_dir($this->cfg['url'].$cp);
if ( $res[$cp] ){
$dir = false;
foreach ( $res[$cp] as $type => $files ){
if ( !$dir && count($files) ){
$dir = $this->fpath.\dirname($files[0]);
}
$this->cfg['num'] += \count($files);
}
/*
if ( $dir && is_file($dir.'/bbn.json') ){
$json = json_decode(file_get_contents($dir.'/bbn.json'));
if ( isset($json->components) ){
foreach ( $json->components as $tmp ){
if ( !isset($res[$tmp]) && !\in_array($tmp, $this->cfg['components'], true) ){
$this->cfg['components'][] = $tmp;
goto cpStart;
break;
}
}
}
}
*/
}
}
}
}
// Last but not least, libraries!
else if ( isset($this->cfg['params']['lib']) ){
$res = $this->get_libs();
// Adding dirs to config
if ( !empty($this->cfg['params']['dirs']) ){
$dirs = explode(',', $this->cfg['params']['dirs']);
foreach ( $dirs as $d ){
if ( $r = $this->get_dir($d) ){
$this->add($res, $r);
}
}
}
}
$this->cfg['content'] = $res ?? [];
return $this;
} | php | protected function _set_files(){
// Shortcuts for files and dir
if ( isset($this->cfg['params']['f']) ){
$this->cfg['params']['files'] = $this->cfg['params']['f'];
unset($this->cfg['params']['f']);
}
if ( isset($this->cfg['params']['d']) ){
$this->cfg['params']['dir'] = $this->cfg['params']['d'];
unset($this->cfg['params']['d']);
}
// File
if ( !empty($this->cfg['ext']) && is_file($this->fpath.$this->cfg['url']) ){
$res = $this->get_file();
}
// Preconfigured
else if ( isset($this->cfg['params']['id']) ){
$res = $this->get_preconfig();
}
// List of files
else if ( isset($this->cfg['params']['files']) && is_dir($this->fpath.$this->cfg['url']) ){
$res = $this->get_files();
}
// Directory content
// Vue component
else if ( isset($this->cfg['params']['dir']) && is_dir($this->fpath.$this->cfg['url']) ){
$res = $this->get_dir();
}
else if ( $this->cfg['is_component'] && is_dir($this->fpath.$this->cfg['url']) ){
//cpStart:
$res = [];
$this->cfg['num'] = 0;
foreach ( $this->cfg['components'] as $i => $cp ){
if ( !isset($res[$cp]) ){
$res[$cp] = $this->get_dir($this->cfg['url'].$cp);
if ( $res[$cp] ){
$dir = false;
foreach ( $res[$cp] as $type => $files ){
if ( !$dir && count($files) ){
$dir = $this->fpath.\dirname($files[0]);
}
$this->cfg['num'] += \count($files);
}
/*
if ( $dir && is_file($dir.'/bbn.json') ){
$json = json_decode(file_get_contents($dir.'/bbn.json'));
if ( isset($json->components) ){
foreach ( $json->components as $tmp ){
if ( !isset($res[$tmp]) && !\in_array($tmp, $this->cfg['components'], true) ){
$this->cfg['components'][] = $tmp;
goto cpStart;
break;
}
}
}
}
*/
}
}
}
}
// Last but not least, libraries!
else if ( isset($this->cfg['params']['lib']) ){
$res = $this->get_libs();
// Adding dirs to config
if ( !empty($this->cfg['params']['dirs']) ){
$dirs = explode(',', $this->cfg['params']['dirs']);
foreach ( $dirs as $d ){
if ( $r = $this->get_dir($d) ){
$this->add($res, $r);
}
}
}
}
$this->cfg['content'] = $res ?? [];
return $this;
} | [
"protected",
"function",
"_set_files",
"(",
")",
"{",
"// Shortcuts for files and dir",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"cfg",
"[",
"'params'",
"]",
"[",
"'f'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"cfg",
"[",
"'params'",
"]",
"[",
"'files'",
"]",
"=",
"$",
"this",
"->",
"cfg",
"[",
"'params'",
"]",
"[",
"'f'",
"]",
";",
"unset",
"(",
"$",
"this",
"->",
"cfg",
"[",
"'params'",
"]",
"[",
"'f'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"cfg",
"[",
"'params'",
"]",
"[",
"'d'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"cfg",
"[",
"'params'",
"]",
"[",
"'dir'",
"]",
"=",
"$",
"this",
"->",
"cfg",
"[",
"'params'",
"]",
"[",
"'d'",
"]",
";",
"unset",
"(",
"$",
"this",
"->",
"cfg",
"[",
"'params'",
"]",
"[",
"'d'",
"]",
")",
";",
"}",
"// File",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"cfg",
"[",
"'ext'",
"]",
")",
"&&",
"is_file",
"(",
"$",
"this",
"->",
"fpath",
".",
"$",
"this",
"->",
"cfg",
"[",
"'url'",
"]",
")",
")",
"{",
"$",
"res",
"=",
"$",
"this",
"->",
"get_file",
"(",
")",
";",
"}",
"// Preconfigured",
"else",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"cfg",
"[",
"'params'",
"]",
"[",
"'id'",
"]",
")",
")",
"{",
"$",
"res",
"=",
"$",
"this",
"->",
"get_preconfig",
"(",
")",
";",
"}",
"// List of files",
"else",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"cfg",
"[",
"'params'",
"]",
"[",
"'files'",
"]",
")",
"&&",
"is_dir",
"(",
"$",
"this",
"->",
"fpath",
".",
"$",
"this",
"->",
"cfg",
"[",
"'url'",
"]",
")",
")",
"{",
"$",
"res",
"=",
"$",
"this",
"->",
"get_files",
"(",
")",
";",
"}",
"// Directory content",
"// Vue component",
"else",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"cfg",
"[",
"'params'",
"]",
"[",
"'dir'",
"]",
")",
"&&",
"is_dir",
"(",
"$",
"this",
"->",
"fpath",
".",
"$",
"this",
"->",
"cfg",
"[",
"'url'",
"]",
")",
")",
"{",
"$",
"res",
"=",
"$",
"this",
"->",
"get_dir",
"(",
")",
";",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"cfg",
"[",
"'is_component'",
"]",
"&&",
"is_dir",
"(",
"$",
"this",
"->",
"fpath",
".",
"$",
"this",
"->",
"cfg",
"[",
"'url'",
"]",
")",
")",
"{",
"//cpStart:",
"$",
"res",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"cfg",
"[",
"'num'",
"]",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"cfg",
"[",
"'components'",
"]",
"as",
"$",
"i",
"=>",
"$",
"cp",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"res",
"[",
"$",
"cp",
"]",
")",
")",
"{",
"$",
"res",
"[",
"$",
"cp",
"]",
"=",
"$",
"this",
"->",
"get_dir",
"(",
"$",
"this",
"->",
"cfg",
"[",
"'url'",
"]",
".",
"$",
"cp",
")",
";",
"if",
"(",
"$",
"res",
"[",
"$",
"cp",
"]",
")",
"{",
"$",
"dir",
"=",
"false",
";",
"foreach",
"(",
"$",
"res",
"[",
"$",
"cp",
"]",
"as",
"$",
"type",
"=>",
"$",
"files",
")",
"{",
"if",
"(",
"!",
"$",
"dir",
"&&",
"count",
"(",
"$",
"files",
")",
")",
"{",
"$",
"dir",
"=",
"$",
"this",
"->",
"fpath",
".",
"\\",
"dirname",
"(",
"$",
"files",
"[",
"0",
"]",
")",
";",
"}",
"$",
"this",
"->",
"cfg",
"[",
"'num'",
"]",
"+=",
"\\",
"count",
"(",
"$",
"files",
")",
";",
"}",
"/*\n if ( $dir && is_file($dir.'/bbn.json') ){\n $json = json_decode(file_get_contents($dir.'/bbn.json'));\n if ( isset($json->components) ){\n foreach ( $json->components as $tmp ){\n if ( !isset($res[$tmp]) && !\\in_array($tmp, $this->cfg['components'], true) ){\n $this->cfg['components'][] = $tmp;\n goto cpStart;\n break;\n }\n }\n }\n }\n */",
"}",
"}",
"}",
"}",
"// Last but not least, libraries!",
"else",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"cfg",
"[",
"'params'",
"]",
"[",
"'lib'",
"]",
")",
")",
"{",
"$",
"res",
"=",
"$",
"this",
"->",
"get_libs",
"(",
")",
";",
"// Adding dirs to config",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"cfg",
"[",
"'params'",
"]",
"[",
"'dirs'",
"]",
")",
")",
"{",
"$",
"dirs",
"=",
"explode",
"(",
"','",
",",
"$",
"this",
"->",
"cfg",
"[",
"'params'",
"]",
"[",
"'dirs'",
"]",
")",
";",
"foreach",
"(",
"$",
"dirs",
"as",
"$",
"d",
")",
"{",
"if",
"(",
"$",
"r",
"=",
"$",
"this",
"->",
"get_dir",
"(",
"$",
"d",
")",
")",
"{",
"$",
"this",
"->",
"add",
"(",
"$",
"res",
",",
"$",
"r",
")",
";",
"}",
"}",
"}",
"}",
"$",
"this",
"->",
"cfg",
"[",
"'content'",
"]",
"=",
"$",
"res",
"??",
"[",
"]",
";",
"return",
"$",
"this",
";",
"}"
] | Returns an array of arrays of types and files; it will use one of the different methods for retrieving files
depending on the params sent
@return $this | [
"Returns",
"an",
"array",
"of",
"arrays",
"of",
"types",
"and",
"files",
";",
"it",
"will",
"use",
"one",
"of",
"the",
"different",
"methods",
"for",
"retrieving",
"files",
"depending",
"on",
"the",
"params",
"sent"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/cdn/config.php#L59-L134 |
surebert/surebert-framework | src/sb/XMPP/Presence.php | Presence.getPriority | public function getPriority($as_string=true)
{
$nodes = $this->doc->getElementsByTagName('priority');
$node =$nodes->item(0);
if($node){
if($as_string){
return $node->nodeValue;
} else {
return $node;
}
} else {
return '';
}
} | php | public function getPriority($as_string=true)
{
$nodes = $this->doc->getElementsByTagName('priority');
$node =$nodes->item(0);
if($node){
if($as_string){
return $node->nodeValue;
} else {
return $node;
}
} else {
return '';
}
} | [
"public",
"function",
"getPriority",
"(",
"$",
"as_string",
"=",
"true",
")",
"{",
"$",
"nodes",
"=",
"$",
"this",
"->",
"doc",
"->",
"getElementsByTagName",
"(",
"'priority'",
")",
";",
"$",
"node",
"=",
"$",
"nodes",
"->",
"item",
"(",
"0",
")",
";",
"if",
"(",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"as_string",
")",
"{",
"return",
"$",
"node",
"->",
"nodeValue",
";",
"}",
"else",
"{",
"return",
"$",
"node",
";",
"}",
"}",
"else",
"{",
"return",
"''",
";",
"}",
"}"
] | Gets the priority value of a presence packet
@param boolean $as_string Determines if node is returned as xml node or string, true by default
@return string | [
"Gets",
"the",
"priority",
"value",
"of",
"a",
"presence",
"packet"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Presence.php#L99-L112 |
surebert/surebert-framework | src/sb/XMPP/Presence.php | Presence.setStatus | public function setStatus($status)
{
$node = $this->getStatus(false);
if(!$node){
$node = $this->createElement('status');
$this->doc->appendChild($node);
}
$node->nodeValue = htmlspecialchars($status);
} | php | public function setStatus($status)
{
$node = $this->getStatus(false);
if(!$node){
$node = $this->createElement('status');
$this->doc->appendChild($node);
}
$node->nodeValue = htmlspecialchars($status);
} | [
"public",
"function",
"setStatus",
"(",
"$",
"status",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"getStatus",
"(",
"false",
")",
";",
"if",
"(",
"!",
"$",
"node",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"createElement",
"(",
"'status'",
")",
";",
"$",
"this",
"->",
"doc",
"->",
"appendChild",
"(",
"$",
"node",
")",
";",
"}",
"$",
"node",
"->",
"nodeValue",
"=",
"htmlspecialchars",
"(",
"$",
"status",
")",
";",
"}"
] | Set the status of the presence packet
@param string $status The status message to display in human readible format | [
"Set",
"the",
"status",
"of",
"the",
"presence",
"packet"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Presence.php#L119-L129 |
surebert/surebert-framework | src/sb/XMPP/Presence.php | Presence.setShow | public function setShow($show)
{
if($show == 'unavailable') {
$this->setType($show);
}
$node = $this->getShow(false);
if(!$node){
$node = $this->createElement('show');
$this->doc->appendChild($node);
}
$node->nodeValue = htmlspecialchars($show);
} | php | public function setShow($show)
{
if($show == 'unavailable') {
$this->setType($show);
}
$node = $this->getShow(false);
if(!$node){
$node = $this->createElement('show');
$this->doc->appendChild($node);
}
$node->nodeValue = htmlspecialchars($show);
} | [
"public",
"function",
"setShow",
"(",
"$",
"show",
")",
"{",
"if",
"(",
"$",
"show",
"==",
"'unavailable'",
")",
"{",
"$",
"this",
"->",
"setType",
"(",
"$",
"show",
")",
";",
"}",
"$",
"node",
"=",
"$",
"this",
"->",
"getShow",
"(",
"false",
")",
";",
"if",
"(",
"!",
"$",
"node",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"createElement",
"(",
"'show'",
")",
";",
"$",
"this",
"->",
"doc",
"->",
"appendChild",
"(",
"$",
"node",
")",
";",
"}",
"$",
"node",
"->",
"nodeValue",
"=",
"htmlspecialchars",
"(",
"$",
"show",
")",
";",
"}"
] | Shows the status of the bot
@param string $show A code to describe the state. see http://xmpp.org/rfcs/rfc3921.html
away - The entity or resource is temporarily away.
chat - The entity or resource is actively interested in chatting.
dnd - The entity or resource is busy (dnd = "Do Not Disturb").
xa - The entity or resource is away for an extended period (xa = "eXtended Away"). | [
"Shows",
"the",
"status",
"of",
"the",
"bot"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Presence.php#L139-L154 |
surebert/surebert-framework | src/sb/XMPP/Presence.php | Presence.setPriority | public function setPriority($priority=1)
{
$node = $this->getPriority(false);
if(!$node){
$node = $this->createElement('priority');
$this->doc->appendChild($node);
}
$node->nodeValue = htmlspecialchars($priority);
} | php | public function setPriority($priority=1)
{
$node = $this->getPriority(false);
if(!$node){
$node = $this->createElement('priority');
$this->doc->appendChild($node);
}
$node->nodeValue = htmlspecialchars($priority);
} | [
"public",
"function",
"setPriority",
"(",
"$",
"priority",
"=",
"1",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"getPriority",
"(",
"false",
")",
";",
"if",
"(",
"!",
"$",
"node",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"createElement",
"(",
"'priority'",
")",
";",
"$",
"this",
"->",
"doc",
"->",
"appendChild",
"(",
"$",
"node",
")",
";",
"}",
"$",
"node",
"->",
"nodeValue",
"=",
"htmlspecialchars",
"(",
"$",
"priority",
")",
";",
"}"
] | Sets the priority of the presence
@param integer $priority | [
"Sets",
"the",
"priority",
"of",
"the",
"presence"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Presence.php#L160-L170 |
surebert/surebert-framework | src/sb/XMPP/Presence.php | Presence.setType | public function setType($type)
{
$attr = $this->createAttribute('type');
$this->doc->appendChild($attr);
$attr->appendChild($this->createTextNode($type));
} | php | public function setType($type)
{
$attr = $this->createAttribute('type');
$this->doc->appendChild($attr);
$attr->appendChild($this->createTextNode($type));
} | [
"public",
"function",
"setType",
"(",
"$",
"type",
")",
"{",
"$",
"attr",
"=",
"$",
"this",
"->",
"createAttribute",
"(",
"'type'",
")",
";",
"$",
"this",
"->",
"doc",
"->",
"appendChild",
"(",
"$",
"attr",
")",
";",
"$",
"attr",
"->",
"appendChild",
"(",
"$",
"this",
"->",
"createTextNode",
"(",
"$",
"type",
")",
")",
";",
"}"
] | Sets the presence type
@param string $type see http://xmpp.org/rfcs/rfc3921.html for more info
unavailable -- Signals that the entity is no longer available for communication.
subscribe -- The sender wishes to subscribe to the recipient's presence.
subscribed -- The sender has allowed the recipient to receive their presence.
unsubscribe -- The sender is unsubscribing from another entity's presence.
unsubscribed -- The subscription request has been denied or a previously-granted subscription has been cancelled.
probe -- A request for an entity's current presence; SHOULD be generated only by a server on behalf of a user.
error -- An error has occurred regarding processing or delivery of a previously-sent presence stanza.
@return boolean If it is written or not | [
"Sets",
"the",
"presence",
"type"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Presence.php#L184-L189 |
juskiewicz/Geolocation | src/Build/CoordinatesBuild.php | CoordinatesBuild.create | public static function create(object $googleData) : Coordinates
{
$build = new self($googleData);
$address = $build->createCoordinatesFromGeometry();
return $address;
} | php | public static function create(object $googleData) : Coordinates
{
$build = new self($googleData);
$address = $build->createCoordinatesFromGeometry();
return $address;
} | [
"public",
"static",
"function",
"create",
"(",
"object",
"$",
"googleData",
")",
":",
"Coordinates",
"{",
"$",
"build",
"=",
"new",
"self",
"(",
"$",
"googleData",
")",
";",
"$",
"address",
"=",
"$",
"build",
"->",
"createCoordinatesFromGeometry",
"(",
")",
";",
"return",
"$",
"address",
";",
"}"
] | create address from google maps api result
@param object $googleData Google single result
@return Coordinates | [
"create",
"address",
"from",
"google",
"maps",
"api",
"result"
] | train | https://github.com/juskiewicz/Geolocation/blob/5d3cd393961b92bdfbe2dfe631fbfb62c72dc36d/src/Build/CoordinatesBuild.php#L19-L25 |
juskiewicz/Geolocation | src/Build/CoordinatesBuild.php | CoordinatesBuild.createCoordinatesFromGeometry | public function createCoordinatesFromGeometry() : Coordinates
{
// create new coordinates object
$coordinates = new Coordinates($this->googleData->geometry->location->lat, $this->googleData->geometry->location->lng);
return $coordinates;
} | php | public function createCoordinatesFromGeometry() : Coordinates
{
// create new coordinates object
$coordinates = new Coordinates($this->googleData->geometry->location->lat, $this->googleData->geometry->location->lng);
return $coordinates;
} | [
"public",
"function",
"createCoordinatesFromGeometry",
"(",
")",
":",
"Coordinates",
"{",
"// create new coordinates object",
"$",
"coordinates",
"=",
"new",
"Coordinates",
"(",
"$",
"this",
"->",
"googleData",
"->",
"geometry",
"->",
"location",
"->",
"lat",
",",
"$",
"this",
"->",
"googleData",
"->",
"geometry",
"->",
"location",
"->",
"lng",
")",
";",
"return",
"$",
"coordinates",
";",
"}"
] | create address from google address components
@return Coordinates | [
"create",
"address",
"from",
"google",
"address",
"components"
] | train | https://github.com/juskiewicz/Geolocation/blob/5d3cd393961b92bdfbe2dfe631fbfb62c72dc36d/src/Build/CoordinatesBuild.php#L40-L46 |
znck/countries | src/UpdateCountriesCommand.php | UpdateCountriesCommand.handle | public function handle()
{
$countries = [];
$data = $this->loader->load('en');
foreach ($data as $key => $name) {
$countries[] = [
'name' => $name,
'code' => "${key}",
];
}
$countries = Collection::make($countries);
$hash = md5($countries->toJson());
if (!$this->option('force') && $hash === $this->hash) {
$this->line("No new country.");
return false;
}
$countryCodes = $countries->pluck('code')->unique();
$existingCountryIDs = Collection::make(
DB::table($this->countries)->whereIn('code', $countryCodes)->pluck('id', 'code')
);
$countries = $countries->map(function ($item) use ($existingCountryIDs) {
if ($existingCountryIDs->has($item['code'])) {
$item['id'] = $existingCountryIDs->get($item['code']);
}
return $item;
});
$countries = $countries->groupBy(function ($item) {
return array_has($item, 'id') ? 'update' : 'create';
});
DB::transaction(function () use ($countries, $hash) {
$create = $countries->get('create', Collection::make());
$update = $countries->get('update', Collection::make());
foreach ($create->chunk(static::QUERY_LIMIT) as $entries) {
DB::table($this->countries)->insert($entries->toArray());
}
foreach ($update as $entries) {
DB::table($this->countries)->where('id', $entries['id'])->update($entries);
}
$this->line("{$create->count()} countries created. {$update->count()} countries updated.");
$this->files->put(storage_path(static::INSTALL_HISTORY), $hash);
});
return true;
} | php | public function handle()
{
$countries = [];
$data = $this->loader->load('en');
foreach ($data as $key => $name) {
$countries[] = [
'name' => $name,
'code' => "${key}",
];
}
$countries = Collection::make($countries);
$hash = md5($countries->toJson());
if (!$this->option('force') && $hash === $this->hash) {
$this->line("No new country.");
return false;
}
$countryCodes = $countries->pluck('code')->unique();
$existingCountryIDs = Collection::make(
DB::table($this->countries)->whereIn('code', $countryCodes)->pluck('id', 'code')
);
$countries = $countries->map(function ($item) use ($existingCountryIDs) {
if ($existingCountryIDs->has($item['code'])) {
$item['id'] = $existingCountryIDs->get($item['code']);
}
return $item;
});
$countries = $countries->groupBy(function ($item) {
return array_has($item, 'id') ? 'update' : 'create';
});
DB::transaction(function () use ($countries, $hash) {
$create = $countries->get('create', Collection::make());
$update = $countries->get('update', Collection::make());
foreach ($create->chunk(static::QUERY_LIMIT) as $entries) {
DB::table($this->countries)->insert($entries->toArray());
}
foreach ($update as $entries) {
DB::table($this->countries)->where('id', $entries['id'])->update($entries);
}
$this->line("{$create->count()} countries created. {$update->count()} countries updated.");
$this->files->put(storage_path(static::INSTALL_HISTORY), $hash);
});
return true;
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"$",
"countries",
"=",
"[",
"]",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"loader",
"->",
"load",
"(",
"'en'",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"name",
")",
"{",
"$",
"countries",
"[",
"]",
"=",
"[",
"'name'",
"=>",
"$",
"name",
",",
"'code'",
"=>",
"\"${key}\"",
",",
"]",
";",
"}",
"$",
"countries",
"=",
"Collection",
"::",
"make",
"(",
"$",
"countries",
")",
";",
"$",
"hash",
"=",
"md5",
"(",
"$",
"countries",
"->",
"toJson",
"(",
")",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"option",
"(",
"'force'",
")",
"&&",
"$",
"hash",
"===",
"$",
"this",
"->",
"hash",
")",
"{",
"$",
"this",
"->",
"line",
"(",
"\"No new country.\"",
")",
";",
"return",
"false",
";",
"}",
"$",
"countryCodes",
"=",
"$",
"countries",
"->",
"pluck",
"(",
"'code'",
")",
"->",
"unique",
"(",
")",
";",
"$",
"existingCountryIDs",
"=",
"Collection",
"::",
"make",
"(",
"DB",
"::",
"table",
"(",
"$",
"this",
"->",
"countries",
")",
"->",
"whereIn",
"(",
"'code'",
",",
"$",
"countryCodes",
")",
"->",
"pluck",
"(",
"'id'",
",",
"'code'",
")",
")",
";",
"$",
"countries",
"=",
"$",
"countries",
"->",
"map",
"(",
"function",
"(",
"$",
"item",
")",
"use",
"(",
"$",
"existingCountryIDs",
")",
"{",
"if",
"(",
"$",
"existingCountryIDs",
"->",
"has",
"(",
"$",
"item",
"[",
"'code'",
"]",
")",
")",
"{",
"$",
"item",
"[",
"'id'",
"]",
"=",
"$",
"existingCountryIDs",
"->",
"get",
"(",
"$",
"item",
"[",
"'code'",
"]",
")",
";",
"}",
"return",
"$",
"item",
";",
"}",
")",
";",
"$",
"countries",
"=",
"$",
"countries",
"->",
"groupBy",
"(",
"function",
"(",
"$",
"item",
")",
"{",
"return",
"array_has",
"(",
"$",
"item",
",",
"'id'",
")",
"?",
"'update'",
":",
"'create'",
";",
"}",
")",
";",
"DB",
"::",
"transaction",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"countries",
",",
"$",
"hash",
")",
"{",
"$",
"create",
"=",
"$",
"countries",
"->",
"get",
"(",
"'create'",
",",
"Collection",
"::",
"make",
"(",
")",
")",
";",
"$",
"update",
"=",
"$",
"countries",
"->",
"get",
"(",
"'update'",
",",
"Collection",
"::",
"make",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"create",
"->",
"chunk",
"(",
"static",
"::",
"QUERY_LIMIT",
")",
"as",
"$",
"entries",
")",
"{",
"DB",
"::",
"table",
"(",
"$",
"this",
"->",
"countries",
")",
"->",
"insert",
"(",
"$",
"entries",
"->",
"toArray",
"(",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"update",
"as",
"$",
"entries",
")",
"{",
"DB",
"::",
"table",
"(",
"$",
"this",
"->",
"countries",
")",
"->",
"where",
"(",
"'id'",
",",
"$",
"entries",
"[",
"'id'",
"]",
")",
"->",
"update",
"(",
"$",
"entries",
")",
";",
"}",
"$",
"this",
"->",
"line",
"(",
"\"{$create->count()} countries created. {$update->count()} countries updated.\"",
")",
";",
"$",
"this",
"->",
"files",
"->",
"put",
"(",
"storage_path",
"(",
"static",
"::",
"INSTALL_HISTORY",
")",
",",
"$",
"hash",
")",
";",
"}",
")",
";",
"return",
"true",
";",
"}"
] | Execute the console command.
@return mixed | [
"Execute",
"the",
"console",
"command",
"."
] | train | https://github.com/znck/countries/blob/a78a2b302dfa8eacab8fe0c06127dbb37fa98fd3/src/UpdateCountriesCommand.php#L86-L141 |
eloquent/phony-kahlan | src/AssertionRecorder.php | AssertionRecorder.createSuccess | public function createSuccess(array $events = []): EventCollection
{
$suiteClass = $this->suiteClass;
$suiteClass::current()->assert($this->successConfig);
return new EventSequence($events, $this->callVerifierFactory);
} | php | public function createSuccess(array $events = []): EventCollection
{
$suiteClass = $this->suiteClass;
$suiteClass::current()->assert($this->successConfig);
return new EventSequence($events, $this->callVerifierFactory);
} | [
"public",
"function",
"createSuccess",
"(",
"array",
"$",
"events",
"=",
"[",
"]",
")",
":",
"EventCollection",
"{",
"$",
"suiteClass",
"=",
"$",
"this",
"->",
"suiteClass",
";",
"$",
"suiteClass",
"::",
"current",
"(",
")",
"->",
"assert",
"(",
"$",
"this",
"->",
"successConfig",
")",
";",
"return",
"new",
"EventSequence",
"(",
"$",
"events",
",",
"$",
"this",
"->",
"callVerifierFactory",
")",
";",
"}"
] | Record that a successful assertion occurred.
@param array<Event> $events The events.
@return EventCollection The result. | [
"Record",
"that",
"a",
"successful",
"assertion",
"occurred",
"."
] | train | https://github.com/eloquent/phony-kahlan/blob/a4654a7edf58268b492acc751ecbeddded9b176f/src/AssertionRecorder.php#L50-L56 |
eloquent/phony-kahlan | src/AssertionRecorder.php | AssertionRecorder.createSuccessFromEventCollection | public function createSuccessFromEventCollection(
EventCollection $events
): EventCollection {
$suiteClass = $this->suiteClass;
$suiteClass::current()->assert($this->successConfig);
return $events;
} | php | public function createSuccessFromEventCollection(
EventCollection $events
): EventCollection {
$suiteClass = $this->suiteClass;
$suiteClass::current()->assert($this->successConfig);
return $events;
} | [
"public",
"function",
"createSuccessFromEventCollection",
"(",
"EventCollection",
"$",
"events",
")",
":",
"EventCollection",
"{",
"$",
"suiteClass",
"=",
"$",
"this",
"->",
"suiteClass",
";",
"$",
"suiteClass",
"::",
"current",
"(",
")",
"->",
"assert",
"(",
"$",
"this",
"->",
"successConfig",
")",
";",
"return",
"$",
"events",
";",
"}"
] | Record that a successful assertion occurred.
@param EventCollection $events The events.
@return EventCollection The result. | [
"Record",
"that",
"a",
"successful",
"assertion",
"occurred",
"."
] | train | https://github.com/eloquent/phony-kahlan/blob/a4654a7edf58268b492acc751ecbeddded9b176f/src/AssertionRecorder.php#L65-L72 |
eloquent/phony-kahlan | src/AssertionRecorder.php | AssertionRecorder.createFailure | public function createFailure(string $description)
{
$exception = new AssertionException($description);
$suiteClass = $this->suiteClass;
$suiteClass::current()->assert([
'handler' => function () use ($exception) {
throw $exception;
},
'type' => AssertionException::class,
]);
} | php | public function createFailure(string $description)
{
$exception = new AssertionException($description);
$suiteClass = $this->suiteClass;
$suiteClass::current()->assert([
'handler' => function () use ($exception) {
throw $exception;
},
'type' => AssertionException::class,
]);
} | [
"public",
"function",
"createFailure",
"(",
"string",
"$",
"description",
")",
"{",
"$",
"exception",
"=",
"new",
"AssertionException",
"(",
"$",
"description",
")",
";",
"$",
"suiteClass",
"=",
"$",
"this",
"->",
"suiteClass",
";",
"$",
"suiteClass",
"::",
"current",
"(",
")",
"->",
"assert",
"(",
"[",
"'handler'",
"=>",
"function",
"(",
")",
"use",
"(",
"$",
"exception",
")",
"{",
"throw",
"$",
"exception",
";",
"}",
",",
"'type'",
"=>",
"AssertionException",
"::",
"class",
",",
"]",
")",
";",
"}"
] | Create a new assertion failure exception.
@param string $description The failure description.
@throws AssertionException The assertion failure. | [
"Create",
"a",
"new",
"assertion",
"failure",
"exception",
"."
] | train | https://github.com/eloquent/phony-kahlan/blob/a4654a7edf58268b492acc751ecbeddded9b176f/src/AssertionRecorder.php#L81-L92 |
blast-project/BaseEntitiesBundle | src/Search/SearchAnalyser.php | SearchAnalyser.analyse | public static function analyse($text)
{
// to lowercase
$text = mb_strtolower(trim($text), 'utf-8');
// remove accents
$text = Transliterator::unaccent($text);
// considering very special chars as spaces
$text = str_replace(array(
'@',
'.', ',', '¿',
'♠', '♣', '♥', '♦',
'-', '+',
'←', '↑', '→', '↓',
"'", '’', '´',
'●', '•',
'¼', '½', '¾',
'“', '”', '„',
'°', '™', '©', '®',
'³', '²',
), ' ', $text);
// remove multiple spaces
$text = preg_replace('/\s+/', ' ', $text);
if ($text) {
return explode(' ', $text);
}
return [];
} | php | public static function analyse($text)
{
// to lowercase
$text = mb_strtolower(trim($text), 'utf-8');
// remove accents
$text = Transliterator::unaccent($text);
// considering very special chars as spaces
$text = str_replace(array(
'@',
'.', ',', '¿',
'♠', '♣', '♥', '♦',
'-', '+',
'←', '↑', '→', '↓',
"'", '’', '´',
'●', '•',
'¼', '½', '¾',
'“', '”', '„',
'°', '™', '©', '®',
'³', '²',
), ' ', $text);
// remove multiple spaces
$text = preg_replace('/\s+/', ' ', $text);
if ($text) {
return explode(' ', $text);
}
return [];
} | [
"public",
"static",
"function",
"analyse",
"(",
"$",
"text",
")",
"{",
"// to lowercase",
"$",
"text",
"=",
"mb_strtolower",
"(",
"trim",
"(",
"$",
"text",
")",
",",
"'utf-8'",
")",
";",
"// remove accents",
"$",
"text",
"=",
"Transliterator",
"::",
"unaccent",
"(",
"$",
"text",
")",
";",
"// considering very special chars as spaces",
"$",
"text",
"=",
"str_replace",
"(",
"array",
"(",
"'@'",
",",
"'.'",
",",
"','",
",",
"'¿',",
"",
"'♠', ",
"'",
"', '♥",
"'",
" '♦',",
"",
"",
"",
"'-'",
",",
"'+'",
",",
"'←', ",
"'",
"', '→",
"'",
" '↓',",
"",
"",
"",
"\"'\"",
",",
"'’', ",
"'",
"',",
"",
"'●', ",
"'",
"',",
"",
"'¼',",
" ",
"½', ",
"'",
"',",
"",
"'“', ",
"'",
"', '„",
"'",
"",
"",
"'°',",
" ",
"™', '",
"©",
", '®",
"'",
"",
"",
"'³',",
" ",
"²',",
"",
")",
",",
"' '",
",",
"$",
"text",
")",
";",
"// remove multiple spaces",
"$",
"text",
"=",
"preg_replace",
"(",
"'/\\s+/'",
",",
"' '",
",",
"$",
"text",
")",
";",
"if",
"(",
"$",
"text",
")",
"{",
"return",
"explode",
"(",
"' '",
",",
"$",
"text",
")",
";",
"}",
"return",
"[",
"]",
";",
"}"
] | @param string $text
@return array | [
"@param",
"string",
"$text"
] | train | https://github.com/blast-project/BaseEntitiesBundle/blob/abd06891fc38922225ab7e4fcb437a286ba2c0c4/src/Search/SearchAnalyser.php#L24-L55 |
php-lug/lug | src/Bundle/ResourceBundle/Rest/View/EventSubscriber/FormViewSubscriber.php | FormViewSubscriber.createFormView | private function createFormView(FormInterface $form)
{
$themes = $this->getParameterResolver()->resolveThemes();
$view = $form->createView();
if (!empty($themes)) {
$this->formRenderer->setTheme($view, $themes);
}
return $view;
} | php | private function createFormView(FormInterface $form)
{
$themes = $this->getParameterResolver()->resolveThemes();
$view = $form->createView();
if (!empty($themes)) {
$this->formRenderer->setTheme($view, $themes);
}
return $view;
} | [
"private",
"function",
"createFormView",
"(",
"FormInterface",
"$",
"form",
")",
"{",
"$",
"themes",
"=",
"$",
"this",
"->",
"getParameterResolver",
"(",
")",
"->",
"resolveThemes",
"(",
")",
";",
"$",
"view",
"=",
"$",
"form",
"->",
"createView",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"themes",
")",
")",
"{",
"$",
"this",
"->",
"formRenderer",
"->",
"setTheme",
"(",
"$",
"view",
",",
"$",
"themes",
")",
";",
"}",
"return",
"$",
"view",
";",
"}"
] | @param FormInterface $form
@return FormView | [
"@param",
"FormInterface",
"$form"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/Rest/View/EventSubscriber/FormViewSubscriber.php#L122-L132 |
MASNathan/Parser | src/Type/Xml.php | Xml.encode | public static function encode($data, $prettyPrint = false, $xmlVersion = '1.0', $encoding = 'utf-8')
{
$domDocument = new DOMDocument($xmlVersion, $encoding);
$domDocument = self::loopEncode($data, $domDocument);
if ($prettyPrint) {
$domDocument->preserveWhiteSpace = false;
$domDocument->formatOutput = true;
}
$resultString = $domDocument->saveXML();
if (!$prettyPrint) {
$resultStringLines = explode(PHP_EOL, $resultString);
$documentLine = array_shift($resultStringLines);
$resultString = $documentLine . PHP_EOL . implode('', $resultStringLines);
} else {
$resultString = trim($resultString, PHP_EOL);
}
return $resultString;
} | php | public static function encode($data, $prettyPrint = false, $xmlVersion = '1.0', $encoding = 'utf-8')
{
$domDocument = new DOMDocument($xmlVersion, $encoding);
$domDocument = self::loopEncode($data, $domDocument);
if ($prettyPrint) {
$domDocument->preserveWhiteSpace = false;
$domDocument->formatOutput = true;
}
$resultString = $domDocument->saveXML();
if (!$prettyPrint) {
$resultStringLines = explode(PHP_EOL, $resultString);
$documentLine = array_shift($resultStringLines);
$resultString = $documentLine . PHP_EOL . implode('', $resultStringLines);
} else {
$resultString = trim($resultString, PHP_EOL);
}
return $resultString;
} | [
"public",
"static",
"function",
"encode",
"(",
"$",
"data",
",",
"$",
"prettyPrint",
"=",
"false",
",",
"$",
"xmlVersion",
"=",
"'1.0'",
",",
"$",
"encoding",
"=",
"'utf-8'",
")",
"{",
"$",
"domDocument",
"=",
"new",
"DOMDocument",
"(",
"$",
"xmlVersion",
",",
"$",
"encoding",
")",
";",
"$",
"domDocument",
"=",
"self",
"::",
"loopEncode",
"(",
"$",
"data",
",",
"$",
"domDocument",
")",
";",
"if",
"(",
"$",
"prettyPrint",
")",
"{",
"$",
"domDocument",
"->",
"preserveWhiteSpace",
"=",
"false",
";",
"$",
"domDocument",
"->",
"formatOutput",
"=",
"true",
";",
"}",
"$",
"resultString",
"=",
"$",
"domDocument",
"->",
"saveXML",
"(",
")",
";",
"if",
"(",
"!",
"$",
"prettyPrint",
")",
"{",
"$",
"resultStringLines",
"=",
"explode",
"(",
"PHP_EOL",
",",
"$",
"resultString",
")",
";",
"$",
"documentLine",
"=",
"array_shift",
"(",
"$",
"resultStringLines",
")",
";",
"$",
"resultString",
"=",
"$",
"documentLine",
".",
"PHP_EOL",
".",
"implode",
"(",
"''",
",",
"$",
"resultStringLines",
")",
";",
"}",
"else",
"{",
"$",
"resultString",
"=",
"trim",
"(",
"$",
"resultString",
",",
"PHP_EOL",
")",
";",
"}",
"return",
"$",
"resultString",
";",
"}"
] | Encodes an array to xml strutcture
@param mixed $data Data to encode
@param boolean $prettyPrint True to output the encoded data a little bit more readable for the humans
@param string $xmlVersion XML header version
@param string $encoding XML header encoding
@return string | [
"Encodes",
"an",
"array",
"to",
"xml",
"strutcture"
] | train | https://github.com/MASNathan/Parser/blob/0f55402b99b1e071bdcd6277b9268f783ca25e34/src/Type/Xml.php#L19-L41 |
MASNathan/Parser | src/Type/Xml.php | Xml.loopEncode | protected static function loopEncode($data, $domElement)
{
if (is_array($data)) {
foreach ($data as $index => $mixedElement) {
if (is_int($index)) {
if ($index == 0) {
$node = $domElement;
} else {
$node = new DOMElement($domElement->tagName);
$domElement->parentNode->appendChild($node);
}
} else {
$node = new DOMElement($index);
$domElement->appendChild($node);
}
self::loopEncode($mixedElement, $node);
}
} else {
$domElement->appendChild(new DOMText($data));
}
return $domElement;
} | php | protected static function loopEncode($data, $domElement)
{
if (is_array($data)) {
foreach ($data as $index => $mixedElement) {
if (is_int($index)) {
if ($index == 0) {
$node = $domElement;
} else {
$node = new DOMElement($domElement->tagName);
$domElement->parentNode->appendChild($node);
}
} else {
$node = new DOMElement($index);
$domElement->appendChild($node);
}
self::loopEncode($mixedElement, $node);
}
} else {
$domElement->appendChild(new DOMText($data));
}
return $domElement;
} | [
"protected",
"static",
"function",
"loopEncode",
"(",
"$",
"data",
",",
"$",
"domElement",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"index",
"=>",
"$",
"mixedElement",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"index",
")",
")",
"{",
"if",
"(",
"$",
"index",
"==",
"0",
")",
"{",
"$",
"node",
"=",
"$",
"domElement",
";",
"}",
"else",
"{",
"$",
"node",
"=",
"new",
"DOMElement",
"(",
"$",
"domElement",
"->",
"tagName",
")",
";",
"$",
"domElement",
"->",
"parentNode",
"->",
"appendChild",
"(",
"$",
"node",
")",
";",
"}",
"}",
"else",
"{",
"$",
"node",
"=",
"new",
"DOMElement",
"(",
"$",
"index",
")",
";",
"$",
"domElement",
"->",
"appendChild",
"(",
"$",
"node",
")",
";",
"}",
"self",
"::",
"loopEncode",
"(",
"$",
"mixedElement",
",",
"$",
"node",
")",
";",
"}",
"}",
"else",
"{",
"$",
"domElement",
"->",
"appendChild",
"(",
"new",
"DOMText",
"(",
"$",
"data",
")",
")",
";",
"}",
"return",
"$",
"domElement",
";",
"}"
] | Lets loop through our data
@param mixed $data Data to encode
@param DOMDocument|DOMElement $domElement Document to initialize and then it'll call itself with inner Element(s)
@return DOMDocument | [
"Lets",
"loop",
"through",
"our",
"data"
] | train | https://github.com/MASNathan/Parser/blob/0f55402b99b1e071bdcd6277b9268f783ca25e34/src/Type/Xml.php#L49-L72 |
MASNathan/Parser | src/Type/Xml.php | Xml.decode | public static function decode($string)
{
$xml = simplexml_load_string($string);
$array = array($xml->getName() => (array) $xml);
$array = self::loopDecode($array);
return $array;
} | php | public static function decode($string)
{
$xml = simplexml_load_string($string);
$array = array($xml->getName() => (array) $xml);
$array = self::loopDecode($array);
return $array;
} | [
"public",
"static",
"function",
"decode",
"(",
"$",
"string",
")",
"{",
"$",
"xml",
"=",
"simplexml_load_string",
"(",
"$",
"string",
")",
";",
"$",
"array",
"=",
"array",
"(",
"$",
"xml",
"->",
"getName",
"(",
")",
"=>",
"(",
"array",
")",
"$",
"xml",
")",
";",
"$",
"array",
"=",
"self",
"::",
"loopDecode",
"(",
"$",
"array",
")",
";",
"return",
"$",
"array",
";",
"}"
] | Decodes a json file string
@param string $string File contents
@return array | [
"Decodes",
"a",
"json",
"file",
"string"
] | train | https://github.com/MASNathan/Parser/blob/0f55402b99b1e071bdcd6277b9268f783ca25e34/src/Type/Xml.php#L79-L86 |
MASNathan/Parser | src/Type/Xml.php | Xml.loopDecode | protected static function loopDecode($data)
{
if (is_array($data)) {
foreach ($data as &$value) {
$value = self::loopDecode($value);
}
} elseif (is_object($data)) {
return self::loopDecode((array) $data);
}
return $data;
} | php | protected static function loopDecode($data)
{
if (is_array($data)) {
foreach ($data as &$value) {
$value = self::loopDecode($value);
}
} elseif (is_object($data)) {
return self::loopDecode((array) $data);
}
return $data;
} | [
"protected",
"static",
"function",
"loopDecode",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"&",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"self",
"::",
"loopDecode",
"(",
"$",
"value",
")",
";",
"}",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"data",
")",
")",
"{",
"return",
"self",
"::",
"loopDecode",
"(",
"(",
"array",
")",
"$",
"data",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Turns all the objects into arrays
@param mixed $data Data
@return array | [
"Turns",
"all",
"the",
"objects",
"into",
"arrays"
] | train | https://github.com/MASNathan/Parser/blob/0f55402b99b1e071bdcd6277b9268f783ca25e34/src/Type/Xml.php#L93-L103 |
surebert/surebert-framework | src/sb/Socket/StreamingClient.php | StreamingClient.open | public function open()
{
$this->log('open socket connection');
$this->socket = @stream_socket_client($this->remote_socket, $errno, $errstr, $this->timeout);
if ($this->socket) {
return true;
} else {
throw(new \Exception("{$errstr} (#{$errno})"));
}
} | php | public function open()
{
$this->log('open socket connection');
$this->socket = @stream_socket_client($this->remote_socket, $errno, $errstr, $this->timeout);
if ($this->socket) {
return true;
} else {
throw(new \Exception("{$errstr} (#{$errno})"));
}
} | [
"public",
"function",
"open",
"(",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"'open socket connection'",
")",
";",
"$",
"this",
"->",
"socket",
"=",
"@",
"stream_socket_client",
"(",
"$",
"this",
"->",
"remote_socket",
",",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"this",
"->",
"timeout",
")",
";",
"if",
"(",
"$",
"this",
"->",
"socket",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"throw",
"(",
"new",
"\\",
"Exception",
"(",
"\"{$errstr} (#{$errno})\"",
")",
")",
";",
"}",
"}"
] | Open the connection
@return boolean Throws exception on error | [
"Open",
"the",
"connection"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Socket/StreamingClient.php#L47-L59 |
surebert/surebert-framework | src/sb/Socket/StreamingClient.php | StreamingClient.read | public function read($byte_count=null)
{
$this->log('read from socket');
$buffer = '';
if(!is_null($byte_count)) {
//read the specified amount of data
$buffer .= fgets($this->socket, 1024);
} else {
//read all the data
while (!feof($this->socket)) {
$buffer .= fgets($this->socket, 1024);
}
}
return $buffer;
} | php | public function read($byte_count=null)
{
$this->log('read from socket');
$buffer = '';
if(!is_null($byte_count)) {
//read the specified amount of data
$buffer .= fgets($this->socket, 1024);
} else {
//read all the data
while (!feof($this->socket)) {
$buffer .= fgets($this->socket, 1024);
}
}
return $buffer;
} | [
"public",
"function",
"read",
"(",
"$",
"byte_count",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"'read from socket'",
")",
";",
"$",
"buffer",
"=",
"''",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"byte_count",
")",
")",
"{",
"//read the specified amount of data",
"$",
"buffer",
".=",
"fgets",
"(",
"$",
"this",
"->",
"socket",
",",
"1024",
")",
";",
"}",
"else",
"{",
"//read all the data",
"while",
"(",
"!",
"feof",
"(",
"$",
"this",
"->",
"socket",
")",
")",
"{",
"$",
"buffer",
".=",
"fgets",
"(",
"$",
"this",
"->",
"socket",
",",
"1024",
")",
";",
"}",
"}",
"return",
"$",
"buffer",
";",
"}"
] | Read data from the socket
@param integer $byte_count The amount of data to read, if not set, it reads until feof
@return string The data read from the socket | [
"Read",
"data",
"from",
"the",
"socket"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Socket/StreamingClient.php#L66-L84 |
wenbinye/PhalconX | src/Annotation/Annotations.php | Annotations.import | public function import(array $classes)
{
foreach ($classes as $class => $alias) {
if (is_integer($class)) {
$class = $alias;
$alias = ClassHelper::getSimpleName($class);
}
if (isset($this->imports[$alias])) {
throw new \RuntimeException("Alias $alias for $class exists, previous is "
. $this->imports[$alias]);
}
$this->imports[$alias] = $class;
}
return $this;
} | php | public function import(array $classes)
{
foreach ($classes as $class => $alias) {
if (is_integer($class)) {
$class = $alias;
$alias = ClassHelper::getSimpleName($class);
}
if (isset($this->imports[$alias])) {
throw new \RuntimeException("Alias $alias for $class exists, previous is "
. $this->imports[$alias]);
}
$this->imports[$alias] = $class;
}
return $this;
} | [
"public",
"function",
"import",
"(",
"array",
"$",
"classes",
")",
"{",
"foreach",
"(",
"$",
"classes",
"as",
"$",
"class",
"=>",
"$",
"alias",
")",
"{",
"if",
"(",
"is_integer",
"(",
"$",
"class",
")",
")",
"{",
"$",
"class",
"=",
"$",
"alias",
";",
"$",
"alias",
"=",
"ClassHelper",
"::",
"getSimpleName",
"(",
"$",
"class",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"imports",
"[",
"$",
"alias",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Alias $alias for $class exists, previous is \"",
".",
"$",
"this",
"->",
"imports",
"[",
"$",
"alias",
"]",
")",
";",
"}",
"$",
"this",
"->",
"imports",
"[",
"$",
"alias",
"]",
"=",
"$",
"class",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Imports annotation classes | [
"Imports",
"annotation",
"classes"
] | train | https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Annotation/Annotations.php#L55-L69 |
wenbinye/PhalconX | src/Annotation/Annotations.php | Annotations.get | public function get($class)
{
$annotations = $this->getCache()->get('_PHX.annotations.' . $class);
if (!isset($annotations)) {
$annotations = $this->getAnnotations($class);
$this->getCache()->save('_PHX.annotations.' . $class, $annotations);
}
return $annotations;
} | php | public function get($class)
{
$annotations = $this->getCache()->get('_PHX.annotations.' . $class);
if (!isset($annotations)) {
$annotations = $this->getAnnotations($class);
$this->getCache()->save('_PHX.annotations.' . $class, $annotations);
}
return $annotations;
} | [
"public",
"function",
"get",
"(",
"$",
"class",
")",
"{",
"$",
"annotations",
"=",
"$",
"this",
"->",
"getCache",
"(",
")",
"->",
"get",
"(",
"'_PHX.annotations.'",
".",
"$",
"class",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"annotations",
")",
")",
"{",
"$",
"annotations",
"=",
"$",
"this",
"->",
"getAnnotations",
"(",
"$",
"class",
")",
";",
"$",
"this",
"->",
"getCache",
"(",
")",
"->",
"save",
"(",
"'_PHX.annotations.'",
".",
"$",
"class",
",",
"$",
"annotations",
")",
";",
"}",
"return",
"$",
"annotations",
";",
"}"
] | Gets all annotations in the class
@param string $class class name
@return array | [
"Gets",
"all",
"annotations",
"in",
"the",
"class"
] | train | https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Annotation/Annotations.php#L94-L102 |
wenbinye/PhalconX | src/Annotation/Annotations.php | Annotations.getAnnotations | private function getAnnotations($class)
{
$parsed = $this->getParser()->parse($class);
if (!is_array($parsed)) {
return [];
}
$context = [
'class' => $class,
'declaringClass' => $class,
'type' => Context::TYPE_CLASS,
'name' => $class
];
$annotations = [];
if (!empty($parsed['class'])) {
foreach ($parsed['class'] as $value) {
$anno = $this->create($value, $context);
if ($anno) {
$annotations[] = $anno;
}
}
}
$map = [
'methods' => Context::TYPE_METHOD,
'properties' => Context::TYPE_PROPERTY
];
$reflection = new \ReflectionClass($class);
foreach ($map as $type_name => $type) {
if (!empty($parsed[$type_name])) {
foreach ($parsed[$type_name] as $name => $values) {
$reflType = $type == 'method' ? $reflection->getMethod($name)
: $reflection->getProperty($name);
$context['type'] = $type;
$context['name'] = $name;
$context['declaringClass'] = $reflType->getDeclaringClass()->getName();
foreach ($values as $value) {
$anno = $this->create($value, $context);
if ($anno) {
$annotations[] = $anno;
}
}
}
}
}
return $annotations;
} | php | private function getAnnotations($class)
{
$parsed = $this->getParser()->parse($class);
if (!is_array($parsed)) {
return [];
}
$context = [
'class' => $class,
'declaringClass' => $class,
'type' => Context::TYPE_CLASS,
'name' => $class
];
$annotations = [];
if (!empty($parsed['class'])) {
foreach ($parsed['class'] as $value) {
$anno = $this->create($value, $context);
if ($anno) {
$annotations[] = $anno;
}
}
}
$map = [
'methods' => Context::TYPE_METHOD,
'properties' => Context::TYPE_PROPERTY
];
$reflection = new \ReflectionClass($class);
foreach ($map as $type_name => $type) {
if (!empty($parsed[$type_name])) {
foreach ($parsed[$type_name] as $name => $values) {
$reflType = $type == 'method' ? $reflection->getMethod($name)
: $reflection->getProperty($name);
$context['type'] = $type;
$context['name'] = $name;
$context['declaringClass'] = $reflType->getDeclaringClass()->getName();
foreach ($values as $value) {
$anno = $this->create($value, $context);
if ($anno) {
$annotations[] = $anno;
}
}
}
}
}
return $annotations;
} | [
"private",
"function",
"getAnnotations",
"(",
"$",
"class",
")",
"{",
"$",
"parsed",
"=",
"$",
"this",
"->",
"getParser",
"(",
")",
"->",
"parse",
"(",
"$",
"class",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"parsed",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"context",
"=",
"[",
"'class'",
"=>",
"$",
"class",
",",
"'declaringClass'",
"=>",
"$",
"class",
",",
"'type'",
"=>",
"Context",
"::",
"TYPE_CLASS",
",",
"'name'",
"=>",
"$",
"class",
"]",
";",
"$",
"annotations",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"parsed",
"[",
"'class'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"parsed",
"[",
"'class'",
"]",
"as",
"$",
"value",
")",
"{",
"$",
"anno",
"=",
"$",
"this",
"->",
"create",
"(",
"$",
"value",
",",
"$",
"context",
")",
";",
"if",
"(",
"$",
"anno",
")",
"{",
"$",
"annotations",
"[",
"]",
"=",
"$",
"anno",
";",
"}",
"}",
"}",
"$",
"map",
"=",
"[",
"'methods'",
"=>",
"Context",
"::",
"TYPE_METHOD",
",",
"'properties'",
"=>",
"Context",
"::",
"TYPE_PROPERTY",
"]",
";",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"foreach",
"(",
"$",
"map",
"as",
"$",
"type_name",
"=>",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"parsed",
"[",
"$",
"type_name",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"parsed",
"[",
"$",
"type_name",
"]",
"as",
"$",
"name",
"=>",
"$",
"values",
")",
"{",
"$",
"reflType",
"=",
"$",
"type",
"==",
"'method'",
"?",
"$",
"reflection",
"->",
"getMethod",
"(",
"$",
"name",
")",
":",
"$",
"reflection",
"->",
"getProperty",
"(",
"$",
"name",
")",
";",
"$",
"context",
"[",
"'type'",
"]",
"=",
"$",
"type",
";",
"$",
"context",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"$",
"context",
"[",
"'declaringClass'",
"]",
"=",
"$",
"reflType",
"->",
"getDeclaringClass",
"(",
")",
"->",
"getName",
"(",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"$",
"anno",
"=",
"$",
"this",
"->",
"create",
"(",
"$",
"value",
",",
"$",
"context",
")",
";",
"if",
"(",
"$",
"anno",
")",
"{",
"$",
"annotations",
"[",
"]",
"=",
"$",
"anno",
";",
"}",
"}",
"}",
"}",
"}",
"return",
"$",
"annotations",
";",
"}"
] | parse all annotations from class | [
"parse",
"all",
"annotations",
"from",
"class"
] | train | https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Annotation/Annotations.php#L129-L173 |
wenbinye/PhalconX | src/Annotation/Annotations.php | Annotations.create | private function create($annotation, $context)
{
$logger = $this->getLogger();
$name = $annotation['name'];
if (!$this->isValidName($name)) {
return null;
}
$annotationClass = $this->resolveClassName($name, $context['declaringClass']);
if (!$annotationClass) {
if (isset($this->imports[$name])) {
$annotationClass = $this->imports[$name];
} else {
$logger->warning("Unknown annotation '$name' at {$annotation['file']}:{$annotation['line']}");
return null;
}
}
if (!class_exists($annotationClass)) {
$logger->warning("Annotation class '$annotationClass' does not exist"
." at {$annotation['file']}:{$annotation['line']}");
return null;
}
if (!is_subclass_of($annotationClass, Annotation::class)) {
$logger->warning("Annotation class '$annotationClass' at {$annotation['file']}:{$annotation['line']}"
." is not subclass of " . Annotation::class);
return null;
}
$context['file'] = $annotation['file'];
$context['line'] = $annotation['line'];
$args = (new PhalconAnnotation($annotation))->getArguments() ?: [];
return new $annotationClass($args, new Context($context));
} | php | private function create($annotation, $context)
{
$logger = $this->getLogger();
$name = $annotation['name'];
if (!$this->isValidName($name)) {
return null;
}
$annotationClass = $this->resolveClassName($name, $context['declaringClass']);
if (!$annotationClass) {
if (isset($this->imports[$name])) {
$annotationClass = $this->imports[$name];
} else {
$logger->warning("Unknown annotation '$name' at {$annotation['file']}:{$annotation['line']}");
return null;
}
}
if (!class_exists($annotationClass)) {
$logger->warning("Annotation class '$annotationClass' does not exist"
." at {$annotation['file']}:{$annotation['line']}");
return null;
}
if (!is_subclass_of($annotationClass, Annotation::class)) {
$logger->warning("Annotation class '$annotationClass' at {$annotation['file']}:{$annotation['line']}"
." is not subclass of " . Annotation::class);
return null;
}
$context['file'] = $annotation['file'];
$context['line'] = $annotation['line'];
$args = (new PhalconAnnotation($annotation))->getArguments() ?: [];
return new $annotationClass($args, new Context($context));
} | [
"private",
"function",
"create",
"(",
"$",
"annotation",
",",
"$",
"context",
")",
"{",
"$",
"logger",
"=",
"$",
"this",
"->",
"getLogger",
"(",
")",
";",
"$",
"name",
"=",
"$",
"annotation",
"[",
"'name'",
"]",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isValidName",
"(",
"$",
"name",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"annotationClass",
"=",
"$",
"this",
"->",
"resolveClassName",
"(",
"$",
"name",
",",
"$",
"context",
"[",
"'declaringClass'",
"]",
")",
";",
"if",
"(",
"!",
"$",
"annotationClass",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"imports",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"annotationClass",
"=",
"$",
"this",
"->",
"imports",
"[",
"$",
"name",
"]",
";",
"}",
"else",
"{",
"$",
"logger",
"->",
"warning",
"(",
"\"Unknown annotation '$name' at {$annotation['file']}:{$annotation['line']}\"",
")",
";",
"return",
"null",
";",
"}",
"}",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"annotationClass",
")",
")",
"{",
"$",
"logger",
"->",
"warning",
"(",
"\"Annotation class '$annotationClass' does not exist\"",
".",
"\" at {$annotation['file']}:{$annotation['line']}\"",
")",
";",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"is_subclass_of",
"(",
"$",
"annotationClass",
",",
"Annotation",
"::",
"class",
")",
")",
"{",
"$",
"logger",
"->",
"warning",
"(",
"\"Annotation class '$annotationClass' at {$annotation['file']}:{$annotation['line']}\"",
".",
"\" is not subclass of \"",
".",
"Annotation",
"::",
"class",
")",
";",
"return",
"null",
";",
"}",
"$",
"context",
"[",
"'file'",
"]",
"=",
"$",
"annotation",
"[",
"'file'",
"]",
";",
"$",
"context",
"[",
"'line'",
"]",
"=",
"$",
"annotation",
"[",
"'line'",
"]",
";",
"$",
"args",
"=",
"(",
"new",
"PhalconAnnotation",
"(",
"$",
"annotation",
")",
")",
"->",
"getArguments",
"(",
")",
"?",
":",
"[",
"]",
";",
"return",
"new",
"$",
"annotationClass",
"(",
"$",
"args",
",",
"new",
"Context",
"(",
"$",
"context",
")",
")",
";",
"}"
] | create annotation object | [
"create",
"annotation",
"object"
] | train | https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Annotation/Annotations.php#L178-L208 |
juskiewicz/Geolocation | src/Build/AddressBuild.php | AddressBuild.create | public static function create(object $googleData) : Address
{
$build = new self($googleData);
$address = $build->createAddressFromComponents();
return $address;
} | php | public static function create(object $googleData) : Address
{
$build = new self($googleData);
$address = $build->createAddressFromComponents();
return $address;
} | [
"public",
"static",
"function",
"create",
"(",
"object",
"$",
"googleData",
")",
":",
"Address",
"{",
"$",
"build",
"=",
"new",
"self",
"(",
"$",
"googleData",
")",
";",
"$",
"address",
"=",
"$",
"build",
"->",
"createAddressFromComponents",
"(",
")",
";",
"return",
"$",
"address",
";",
"}"
] | create address from google maps api result
@param object $googleData Google single result
@return Address | [
"create",
"address",
"from",
"google",
"maps",
"api",
"result"
] | train | https://github.com/juskiewicz/Geolocation/blob/5d3cd393961b92bdfbe2dfe631fbfb62c72dc36d/src/Build/AddressBuild.php#L19-L25 |
juskiewicz/Geolocation | src/Build/AddressBuild.php | AddressBuild.createAddressFromComponents | public function createAddressFromComponents() : Address
{
// create new address object
$address = new Address();
// update address from google address components
foreach ($this->googleData->address_components as $component) {
$this->updateAddressFromComponent($address, $component);
}
return $address;
} | php | public function createAddressFromComponents() : Address
{
// create new address object
$address = new Address();
// update address from google address components
foreach ($this->googleData->address_components as $component) {
$this->updateAddressFromComponent($address, $component);
}
return $address;
} | [
"public",
"function",
"createAddressFromComponents",
"(",
")",
":",
"Address",
"{",
"// create new address object",
"$",
"address",
"=",
"new",
"Address",
"(",
")",
";",
"// update address from google address components",
"foreach",
"(",
"$",
"this",
"->",
"googleData",
"->",
"address_components",
"as",
"$",
"component",
")",
"{",
"$",
"this",
"->",
"updateAddressFromComponent",
"(",
"$",
"address",
",",
"$",
"component",
")",
";",
"}",
"return",
"$",
"address",
";",
"}"
] | create address from google address components
@return Address | [
"create",
"address",
"from",
"google",
"address",
"components"
] | train | https://github.com/juskiewicz/Geolocation/blob/5d3cd393961b92bdfbe2dfe631fbfb62c72dc36d/src/Build/AddressBuild.php#L40-L51 |
juskiewicz/Geolocation | src/Build/AddressBuild.php | AddressBuild.updateAddressFromComponent | private function updateAddressFromComponent(Address $address, $component) : Address
{
foreach ($component->types as $type) {
switch ($type) {
case 'postal_code':
$address->setPostalCode($component->long_name);
break;
case 'locality':
case 'postal_town':
$address->setLocality($component->long_name);
break;
case 'country':
$address->setCountry($component->long_name);
$address->setCountryCode($component->short_name);
break;
case 'street_number':
$address->setStreetNumber($component->long_name);
break;
case 'route':
$address->setStreetName($component->long_name);
break;
case 'administrative_area_level_1':
case 'administrative_area_level_2':
case 'administrative_area_level_3':
case 'administrative_area_level_4':
case 'administrative_area_level_5':
case 'sublocality':
case 'sublocality_level_1':
case 'sublocality_level_2':
case 'sublocality_level_3':
case 'sublocality_level_4':
case 'sublocality_level_5':
case 'street_address':
case 'intersection':
case 'political':
case 'colloquial_area':
case 'ward':
case 'neighborhood':
case 'premise':
case 'subpremise':
case 'natural_feature':
case 'airport':
case 'park':
case 'point_of_interest':
case 'establishment':
// TODO implements method
break;
default:
}
}
return $address;
} | php | private function updateAddressFromComponent(Address $address, $component) : Address
{
foreach ($component->types as $type) {
switch ($type) {
case 'postal_code':
$address->setPostalCode($component->long_name);
break;
case 'locality':
case 'postal_town':
$address->setLocality($component->long_name);
break;
case 'country':
$address->setCountry($component->long_name);
$address->setCountryCode($component->short_name);
break;
case 'street_number':
$address->setStreetNumber($component->long_name);
break;
case 'route':
$address->setStreetName($component->long_name);
break;
case 'administrative_area_level_1':
case 'administrative_area_level_2':
case 'administrative_area_level_3':
case 'administrative_area_level_4':
case 'administrative_area_level_5':
case 'sublocality':
case 'sublocality_level_1':
case 'sublocality_level_2':
case 'sublocality_level_3':
case 'sublocality_level_4':
case 'sublocality_level_5':
case 'street_address':
case 'intersection':
case 'political':
case 'colloquial_area':
case 'ward':
case 'neighborhood':
case 'premise':
case 'subpremise':
case 'natural_feature':
case 'airport':
case 'park':
case 'point_of_interest':
case 'establishment':
// TODO implements method
break;
default:
}
}
return $address;
} | [
"private",
"function",
"updateAddressFromComponent",
"(",
"Address",
"$",
"address",
",",
"$",
"component",
")",
":",
"Address",
"{",
"foreach",
"(",
"$",
"component",
"->",
"types",
"as",
"$",
"type",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'postal_code'",
":",
"$",
"address",
"->",
"setPostalCode",
"(",
"$",
"component",
"->",
"long_name",
")",
";",
"break",
";",
"case",
"'locality'",
":",
"case",
"'postal_town'",
":",
"$",
"address",
"->",
"setLocality",
"(",
"$",
"component",
"->",
"long_name",
")",
";",
"break",
";",
"case",
"'country'",
":",
"$",
"address",
"->",
"setCountry",
"(",
"$",
"component",
"->",
"long_name",
")",
";",
"$",
"address",
"->",
"setCountryCode",
"(",
"$",
"component",
"->",
"short_name",
")",
";",
"break",
";",
"case",
"'street_number'",
":",
"$",
"address",
"->",
"setStreetNumber",
"(",
"$",
"component",
"->",
"long_name",
")",
";",
"break",
";",
"case",
"'route'",
":",
"$",
"address",
"->",
"setStreetName",
"(",
"$",
"component",
"->",
"long_name",
")",
";",
"break",
";",
"case",
"'administrative_area_level_1'",
":",
"case",
"'administrative_area_level_2'",
":",
"case",
"'administrative_area_level_3'",
":",
"case",
"'administrative_area_level_4'",
":",
"case",
"'administrative_area_level_5'",
":",
"case",
"'sublocality'",
":",
"case",
"'sublocality_level_1'",
":",
"case",
"'sublocality_level_2'",
":",
"case",
"'sublocality_level_3'",
":",
"case",
"'sublocality_level_4'",
":",
"case",
"'sublocality_level_5'",
":",
"case",
"'street_address'",
":",
"case",
"'intersection'",
":",
"case",
"'political'",
":",
"case",
"'colloquial_area'",
":",
"case",
"'ward'",
":",
"case",
"'neighborhood'",
":",
"case",
"'premise'",
":",
"case",
"'subpremise'",
":",
"case",
"'natural_feature'",
":",
"case",
"'airport'",
":",
"case",
"'park'",
":",
"case",
"'point_of_interest'",
":",
"case",
"'establishment'",
":",
"// TODO implements method",
"break",
";",
"default",
":",
"}",
"}",
"return",
"$",
"address",
";",
"}"
] | update address from google address component
@param Address $address
@param object $component Google address component object
@return Address | [
"update",
"address",
"from",
"google",
"address",
"component"
] | train | https://github.com/juskiewicz/Geolocation/blob/5d3cd393961b92bdfbe2dfe631fbfb62c72dc36d/src/Build/AddressBuild.php#L60-L112 |
graze/data-structure | src/Container/FlatContainer.php | FlatContainer.getChild | private function getChild($key)
{
$top = $this->params;
foreach (explode($this->delimiter, $key) as $node) {
if (!isset($top[$node])) {
return null;
}
$top = $top[$node];
}
return $top;
} | php | private function getChild($key)
{
$top = $this->params;
foreach (explode($this->delimiter, $key) as $node) {
if (!isset($top[$node])) {
return null;
}
$top = $top[$node];
}
return $top;
} | [
"private",
"function",
"getChild",
"(",
"$",
"key",
")",
"{",
"$",
"top",
"=",
"$",
"this",
"->",
"params",
";",
"foreach",
"(",
"explode",
"(",
"$",
"this",
"->",
"delimiter",
",",
"$",
"key",
")",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"top",
"[",
"$",
"node",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"top",
"=",
"$",
"top",
"[",
"$",
"node",
"]",
";",
"}",
"return",
"$",
"top",
";",
"}"
] | @param string $key
@return mixed|null | [
"@param",
"string",
"$key"
] | train | https://github.com/graze/data-structure/blob/24e0544b7828f65b1b93ce69ad702c9efb4a64d0/src/Container/FlatContainer.php#L54-L65 |
graze/data-structure | src/Container/FlatContainer.php | FlatContainer.splitToLast | private function splitToLast($key)
{
$split = explode($this->delimiter, $key);
$key = implode($this->delimiter, array_slice($split, 0, -1));
$last = end($split);
return [$key, $last];
} | php | private function splitToLast($key)
{
$split = explode($this->delimiter, $key);
$key = implode($this->delimiter, array_slice($split, 0, -1));
$last = end($split);
return [$key, $last];
} | [
"private",
"function",
"splitToLast",
"(",
"$",
"key",
")",
"{",
"$",
"split",
"=",
"explode",
"(",
"$",
"this",
"->",
"delimiter",
",",
"$",
"key",
")",
";",
"$",
"key",
"=",
"implode",
"(",
"$",
"this",
"->",
"delimiter",
",",
"array_slice",
"(",
"$",
"split",
",",
"0",
",",
"-",
"1",
")",
")",
";",
"$",
"last",
"=",
"end",
"(",
"$",
"split",
")",
";",
"return",
"[",
"$",
"key",
",",
"$",
"last",
"]",
";",
"}"
] | @param string $key
@return string[] split the key into everything up to the last delimiter, and the last key | [
"@param",
"string",
"$key"
] | train | https://github.com/graze/data-structure/blob/24e0544b7828f65b1b93ce69ad702c9efb4a64d0/src/Container/FlatContainer.php#L72-L79 |
graze/data-structure | src/Container/FlatContainer.php | FlatContainer.has | public function has($key)
{
if (mb_strpos($key, $this->delimiter) !== false) {
return (!is_null($this->getChild($key)));
}
return parent::has($key);
} | php | public function has($key)
{
if (mb_strpos($key, $this->delimiter) !== false) {
return (!is_null($this->getChild($key)));
}
return parent::has($key);
} | [
"public",
"function",
"has",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"mb_strpos",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"delimiter",
")",
"!==",
"false",
")",
"{",
"return",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"getChild",
"(",
"$",
"key",
")",
")",
")",
";",
"}",
"return",
"parent",
"::",
"has",
"(",
"$",
"key",
")",
";",
"}"
] | @param string $key The key to access, supports delimiter based child access (e.g. `parent.child.node`)
@return bool | [
"@param",
"string",
"$key",
"The",
"key",
"to",
"access",
"supports",
"delimiter",
"based",
"child",
"access",
"(",
"e",
".",
"g",
".",
"parent",
".",
"child",
".",
"node",
")"
] | train | https://github.com/graze/data-structure/blob/24e0544b7828f65b1b93ce69ad702c9efb4a64d0/src/Container/FlatContainer.php#L86-L92 |
graze/data-structure | src/Container/FlatContainer.php | FlatContainer.get | public function get($key)
{
if (mb_strpos($key, $this->delimiter) !== false) {
return $this->getChild($key);
}
return parent::get($key);
} | php | public function get($key)
{
if (mb_strpos($key, $this->delimiter) !== false) {
return $this->getChild($key);
}
return parent::get($key);
} | [
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"mb_strpos",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"delimiter",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"getChild",
"(",
"$",
"key",
")",
";",
"}",
"return",
"parent",
"::",
"get",
"(",
"$",
"key",
")",
";",
"}"
] | @param string $key The key to access, supports delimiter based child access (e.g. `parent.child.node`)
@return mixed|null | [
"@param",
"string",
"$key",
"The",
"key",
"to",
"access",
"supports",
"delimiter",
"based",
"child",
"access",
"(",
"e",
".",
"g",
".",
"parent",
".",
"child",
".",
"node",
")"
] | train | https://github.com/graze/data-structure/blob/24e0544b7828f65b1b93ce69ad702c9efb4a64d0/src/Container/FlatContainer.php#L99-L106 |
graze/data-structure | src/Container/FlatContainer.php | FlatContainer.doRemove | protected function doRemove($key)
{
if (mb_strpos($key, $this->delimiter) !== false) {
list($key, $last) = $this->splitToLast($key);
$top = $this->get($key);
if (is_null($top) || (!is_array($top) && !($top instanceof ArrayAccess))) {
return $this;
}
if ($top instanceof ContainerInterface) {
$top = $top->remove($last);
} else {
unset($top[$last]);
}
return $this->doSet($key, $top);
}
return parent::remove($key);
} | php | protected function doRemove($key)
{
if (mb_strpos($key, $this->delimiter) !== false) {
list($key, $last) = $this->splitToLast($key);
$top = $this->get($key);
if (is_null($top) || (!is_array($top) && !($top instanceof ArrayAccess))) {
return $this;
}
if ($top instanceof ContainerInterface) {
$top = $top->remove($last);
} else {
unset($top[$last]);
}
return $this->doSet($key, $top);
}
return parent::remove($key);
} | [
"protected",
"function",
"doRemove",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"mb_strpos",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"delimiter",
")",
"!==",
"false",
")",
"{",
"list",
"(",
"$",
"key",
",",
"$",
"last",
")",
"=",
"$",
"this",
"->",
"splitToLast",
"(",
"$",
"key",
")",
";",
"$",
"top",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"key",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"top",
")",
"||",
"(",
"!",
"is_array",
"(",
"$",
"top",
")",
"&&",
"!",
"(",
"$",
"top",
"instanceof",
"ArrayAccess",
")",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"$",
"top",
"instanceof",
"ContainerInterface",
")",
"{",
"$",
"top",
"=",
"$",
"top",
"->",
"remove",
"(",
"$",
"last",
")",
";",
"}",
"else",
"{",
"unset",
"(",
"$",
"top",
"[",
"$",
"last",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"doSet",
"(",
"$",
"key",
",",
"$",
"top",
")",
";",
"}",
"return",
"parent",
"::",
"remove",
"(",
"$",
"key",
")",
";",
"}"
] | @param string $key
@return ContainerInterface | [
"@param",
"string",
"$key"
] | train | https://github.com/graze/data-structure/blob/24e0544b7828f65b1b93ce69ad702c9efb4a64d0/src/Container/FlatContainer.php#L162-L182 |
surebert/surebert-framework | src/sb/Cache/FileSystem.php | FileSystem.store | public function store($key, $data, $lifetime = 0)
{
$file_path = $this->getFilePath($key);
$dir = \dirname($file_path);
if (!is_dir($dir)) {
try {
\mkdir($dir, 0777, true);
} catch (Exception $e) {
throw new \Exception('Could create cache directory: ' . $file_path . " - " . $e->getMessage());
}
}
try {
$fh = \fopen($file_path, 'a+');
} catch (\Exception $e) {
throw new \Exception('Could not write to cache: ' . $file_path . " - " . $e->getMessage());
}
//exclusive lock
\flock($fh, LOCK_EX);
\fseek($fh, 0);
\ftruncate($fh, 0);
if ($lifetime != 0) {
$lifetime = time() + $lifetime;
}
$data = \serialize(array($lifetime, $data));
if (\fwrite($fh, $data) === false) {
throw new \Exception('Could not write to cache: ' . $file_path);
}
\fclose($fh);
if ($key != $this->catalog_key) {
$this->catalogKeyAdd($key, $lifetime);
}
return true;
} | php | public function store($key, $data, $lifetime = 0)
{
$file_path = $this->getFilePath($key);
$dir = \dirname($file_path);
if (!is_dir($dir)) {
try {
\mkdir($dir, 0777, true);
} catch (Exception $e) {
throw new \Exception('Could create cache directory: ' . $file_path . " - " . $e->getMessage());
}
}
try {
$fh = \fopen($file_path, 'a+');
} catch (\Exception $e) {
throw new \Exception('Could not write to cache: ' . $file_path . " - " . $e->getMessage());
}
//exclusive lock
\flock($fh, LOCK_EX);
\fseek($fh, 0);
\ftruncate($fh, 0);
if ($lifetime != 0) {
$lifetime = time() + $lifetime;
}
$data = \serialize(array($lifetime, $data));
if (\fwrite($fh, $data) === false) {
throw new \Exception('Could not write to cache: ' . $file_path);
}
\fclose($fh);
if ($key != $this->catalog_key) {
$this->catalogKeyAdd($key, $lifetime);
}
return true;
} | [
"public",
"function",
"store",
"(",
"$",
"key",
",",
"$",
"data",
",",
"$",
"lifetime",
"=",
"0",
")",
"{",
"$",
"file_path",
"=",
"$",
"this",
"->",
"getFilePath",
"(",
"$",
"key",
")",
";",
"$",
"dir",
"=",
"\\",
"dirname",
"(",
"$",
"file_path",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"try",
"{",
"\\",
"mkdir",
"(",
"$",
"dir",
",",
"0777",
",",
"true",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Could create cache directory: '",
".",
"$",
"file_path",
".",
"\" - \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"try",
"{",
"$",
"fh",
"=",
"\\",
"fopen",
"(",
"$",
"file_path",
",",
"'a+'",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Could not write to cache: '",
".",
"$",
"file_path",
".",
"\" - \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"//exclusive lock",
"\\",
"flock",
"(",
"$",
"fh",
",",
"LOCK_EX",
")",
";",
"\\",
"fseek",
"(",
"$",
"fh",
",",
"0",
")",
";",
"\\",
"ftruncate",
"(",
"$",
"fh",
",",
"0",
")",
";",
"if",
"(",
"$",
"lifetime",
"!=",
"0",
")",
"{",
"$",
"lifetime",
"=",
"time",
"(",
")",
"+",
"$",
"lifetime",
";",
"}",
"$",
"data",
"=",
"\\",
"serialize",
"(",
"array",
"(",
"$",
"lifetime",
",",
"$",
"data",
")",
")",
";",
"if",
"(",
"\\",
"fwrite",
"(",
"$",
"fh",
",",
"$",
"data",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Could not write to cache: '",
".",
"$",
"file_path",
")",
";",
"}",
"\\",
"fclose",
"(",
"$",
"fh",
")",
";",
"if",
"(",
"$",
"key",
"!=",
"$",
"this",
"->",
"catalog_key",
")",
"{",
"$",
"this",
"->",
"catalogKeyAdd",
"(",
"$",
"key",
",",
"$",
"lifetime",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Stores the cached data in /private/cache filesystem | [
"Stores",
"the",
"cached",
"data",
"in",
"/",
"private",
"/",
"cache",
"filesystem"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Cache/FileSystem.php#L64-L106 |
surebert/surebert-framework | src/sb/Cache/FileSystem.php | FileSystem.fetch | public function fetch($key)
{
$file_name = $this->getFilePath($key);
if (!\file_exists($file_name) || !\is_readable($file_name)) {
return false;
} else {
$h = \fopen($file_name, 'r');
//lock file
\flock($h, LOCK_SH);
}
$data = \file_get_contents($file_name);
//release lock
\fclose($h);
$data = @\unserialize($data);
//check to see if it expired
if ($data && ($data[0] == 0 || time() <= $data[0])) {
return $data[1];
} else {
$this->delete($key);
return false;
}
return $data[1];
} | php | public function fetch($key)
{
$file_name = $this->getFilePath($key);
if (!\file_exists($file_name) || !\is_readable($file_name)) {
return false;
} else {
$h = \fopen($file_name, 'r');
//lock file
\flock($h, LOCK_SH);
}
$data = \file_get_contents($file_name);
//release lock
\fclose($h);
$data = @\unserialize($data);
//check to see if it expired
if ($data && ($data[0] == 0 || time() <= $data[0])) {
return $data[1];
} else {
$this->delete($key);
return false;
}
return $data[1];
} | [
"public",
"function",
"fetch",
"(",
"$",
"key",
")",
"{",
"$",
"file_name",
"=",
"$",
"this",
"->",
"getFilePath",
"(",
"$",
"key",
")",
";",
"if",
"(",
"!",
"\\",
"file_exists",
"(",
"$",
"file_name",
")",
"||",
"!",
"\\",
"is_readable",
"(",
"$",
"file_name",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"$",
"h",
"=",
"\\",
"fopen",
"(",
"$",
"file_name",
",",
"'r'",
")",
";",
"//lock file",
"\\",
"flock",
"(",
"$",
"h",
",",
"LOCK_SH",
")",
";",
"}",
"$",
"data",
"=",
"\\",
"file_get_contents",
"(",
"$",
"file_name",
")",
";",
"//release lock",
"\\",
"fclose",
"(",
"$",
"h",
")",
";",
"$",
"data",
"=",
"@",
"\\",
"unserialize",
"(",
"$",
"data",
")",
";",
"//check to see if it expired",
"if",
"(",
"$",
"data",
"&&",
"(",
"$",
"data",
"[",
"0",
"]",
"==",
"0",
"||",
"time",
"(",
")",
"<=",
"$",
"data",
"[",
"0",
"]",
")",
")",
"{",
"return",
"$",
"data",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"delete",
"(",
"$",
"key",
")",
";",
"return",
"false",
";",
"}",
"return",
"$",
"data",
"[",
"1",
"]",
";",
"}"
] | Retreives data from /private/cache | [
"Retreives",
"data",
"from",
"/",
"private",
"/",
"cache"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Cache/FileSystem.php#L111-L138 |
surebert/surebert-framework | src/sb/Cache/FileSystem.php | FileSystem.delete | public function delete($key)
{
$file = $this->getFilePath($key);
if (\is_dir($file)) {
$this->clearDir($file);
$deleted = \rmdir($file);
} elseif (\file_exists($file)) {
$deleted = \unlink($file);
} else {
$deleted = false;
}
if ($deleted) {
$this->catalogKeyDelete($key);
}
return $deleted;
} | php | public function delete($key)
{
$file = $this->getFilePath($key);
if (\is_dir($file)) {
$this->clearDir($file);
$deleted = \rmdir($file);
} elseif (\file_exists($file)) {
$deleted = \unlink($file);
} else {
$deleted = false;
}
if ($deleted) {
$this->catalogKeyDelete($key);
}
return $deleted;
} | [
"public",
"function",
"delete",
"(",
"$",
"key",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getFilePath",
"(",
"$",
"key",
")",
";",
"if",
"(",
"\\",
"is_dir",
"(",
"$",
"file",
")",
")",
"{",
"$",
"this",
"->",
"clearDir",
"(",
"$",
"file",
")",
";",
"$",
"deleted",
"=",
"\\",
"rmdir",
"(",
"$",
"file",
")",
";",
"}",
"elseif",
"(",
"\\",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"$",
"deleted",
"=",
"\\",
"unlink",
"(",
"$",
"file",
")",
";",
"}",
"else",
"{",
"$",
"deleted",
"=",
"false",
";",
"}",
"if",
"(",
"$",
"deleted",
")",
"{",
"$",
"this",
"->",
"catalogKeyDelete",
"(",
"$",
"key",
")",
";",
"}",
"return",
"$",
"deleted",
";",
"}"
] | Deletes data from /private/cache | [
"Deletes",
"data",
"from",
"/",
"private",
"/",
"cache"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Cache/FileSystem.php#L143-L161 |
surebert/surebert-framework | src/sb/Cache/FileSystem.php | FileSystem.clearDir | protected function clearDir($dir)
{
$iterator = new \DirectoryIterator($dir);
foreach ($iterator as $file) {
if ($file->isDir() && !$file->isDot() && !preg_match("~\.~", $file)) {
$this->clearDir($file->getPathname());
if (!\rmdir($file->getPathname())) {
return false;
}
} elseif ($file->isFile()) {
if (!\unlink($file->getPathname())) {
return false;
}
}
}
return true;
} | php | protected function clearDir($dir)
{
$iterator = new \DirectoryIterator($dir);
foreach ($iterator as $file) {
if ($file->isDir() && !$file->isDot() && !preg_match("~\.~", $file)) {
$this->clearDir($file->getPathname());
if (!\rmdir($file->getPathname())) {
return false;
}
} elseif ($file->isFile()) {
if (!\unlink($file->getPathname())) {
return false;
}
}
}
return true;
} | [
"protected",
"function",
"clearDir",
"(",
"$",
"dir",
")",
"{",
"$",
"iterator",
"=",
"new",
"\\",
"DirectoryIterator",
"(",
"$",
"dir",
")",
";",
"foreach",
"(",
"$",
"iterator",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"file",
"->",
"isDir",
"(",
")",
"&&",
"!",
"$",
"file",
"->",
"isDot",
"(",
")",
"&&",
"!",
"preg_match",
"(",
"\"~\\.~\"",
",",
"$",
"file",
")",
")",
"{",
"$",
"this",
"->",
"clearDir",
"(",
"$",
"file",
"->",
"getPathname",
"(",
")",
")",
";",
"if",
"(",
"!",
"\\",
"rmdir",
"(",
"$",
"file",
"->",
"getPathname",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"elseif",
"(",
"$",
"file",
"->",
"isFile",
"(",
")",
")",
"{",
"if",
"(",
"!",
"\\",
"unlink",
"(",
"$",
"file",
"->",
"getPathname",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"return",
"true",
";",
"}"
] | Clears out the contents of a cache directory
@param $dir
@return boolean | [
"Clears",
"out",
"the",
"contents",
"of",
"a",
"cache",
"directory"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Cache/FileSystem.php#L177-L195 |
surebert/surebert-framework | src/sb/Cache/FileSystem.php | FileSystem.catalogKeyDelete | protected function catalogKeyDelete($key)
{
$catalog = $this->fetch($this->catalog_key);
$catalog = \is_array($catalog) ? $catalog : Array();
if (isset($catalog[$key])) {
unset($catalog[$key]);
};
return $this->store('/sb_Cache_Catalog', $catalog);
} | php | protected function catalogKeyDelete($key)
{
$catalog = $this->fetch($this->catalog_key);
$catalog = \is_array($catalog) ? $catalog : Array();
if (isset($catalog[$key])) {
unset($catalog[$key]);
};
return $this->store('/sb_Cache_Catalog', $catalog);
} | [
"protected",
"function",
"catalogKeyDelete",
"(",
"$",
"key",
")",
"{",
"$",
"catalog",
"=",
"$",
"this",
"->",
"fetch",
"(",
"$",
"this",
"->",
"catalog_key",
")",
";",
"$",
"catalog",
"=",
"\\",
"is_array",
"(",
"$",
"catalog",
")",
"?",
"$",
"catalog",
":",
"Array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"catalog",
"[",
"$",
"key",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"catalog",
"[",
"$",
"key",
"]",
")",
";",
"}",
";",
"return",
"$",
"this",
"->",
"store",
"(",
"'/sb_Cache_Catalog'",
",",
"$",
"catalog",
")",
";",
"}"
] | Deletes a key from the catalog
@param string $key The key to delete
@return boolean | [
"Deletes",
"a",
"key",
"from",
"the",
"catalog"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Cache/FileSystem.php#L226-L235 |
surebert/surebert-framework | src/sb/Cache/FileSystem.php | FileSystem.getKeys | public function getKeys()
{
$catalog = $this->fetch($this->catalog_key);
$catalog = \is_array($catalog) ? $catalog : Array();
\ksort($catalog);
return $catalog;
} | php | public function getKeys()
{
$catalog = $this->fetch($this->catalog_key);
$catalog = \is_array($catalog) ? $catalog : Array();
\ksort($catalog);
return $catalog;
} | [
"public",
"function",
"getKeys",
"(",
")",
"{",
"$",
"catalog",
"=",
"$",
"this",
"->",
"fetch",
"(",
"$",
"this",
"->",
"catalog_key",
")",
";",
"$",
"catalog",
"=",
"\\",
"is_array",
"(",
"$",
"catalog",
")",
"?",
"$",
"catalog",
":",
"Array",
"(",
")",
";",
"\\",
"ksort",
"(",
"$",
"catalog",
")",
";",
"return",
"$",
"catalog",
";",
"}"
] | Loads the current catalog
@return Array a list of all keys stored in the cache | [
"Loads",
"the",
"current",
"catalog"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Cache/FileSystem.php#L254-L260 |
caffeinated/beverage | src/Publisher.php | Publisher.publish | public function publish()
{
$destination = config_path('packages/' . $this->package);
if (! $this->files->exists($this->sourcePath)) {
return;
}
if (! $this->files->exists($this->destinationPath)) {
$this->files->makeDirectory($destination, 0755, true);
}
$this->files->copyDirectory($this->sourcePath, $destination);
} | php | public function publish()
{
$destination = config_path('packages/' . $this->package);
if (! $this->files->exists($this->sourcePath)) {
return;
}
if (! $this->files->exists($this->destinationPath)) {
$this->files->makeDirectory($destination, 0755, true);
}
$this->files->copyDirectory($this->sourcePath, $destination);
} | [
"public",
"function",
"publish",
"(",
")",
"{",
"$",
"destination",
"=",
"config_path",
"(",
"'packages/'",
".",
"$",
"this",
"->",
"package",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"files",
"->",
"exists",
"(",
"$",
"this",
"->",
"sourcePath",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"files",
"->",
"exists",
"(",
"$",
"this",
"->",
"destinationPath",
")",
")",
"{",
"$",
"this",
"->",
"files",
"->",
"makeDirectory",
"(",
"$",
"destination",
",",
"0755",
",",
"true",
")",
";",
"}",
"$",
"this",
"->",
"files",
"->",
"copyDirectory",
"(",
"$",
"this",
"->",
"sourcePath",
",",
"$",
"destination",
")",
";",
"}"
] | publish | [
"publish"
] | train | https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Publisher.php#L49-L59 |
thecodingmachine/security.userservice | src/Mouf/Security/UserService/RememberMeAuthProvider.php | RememberMeAuthProvider.isLogged | public function isLogged(UserServiceInterface $userService)
{
$user = $this->getAndLogUserByCookie($userService);
if ($user) {
$this->refreshRememberCookie($user, false);
return true;
} else {
return false;
}
} | php | public function isLogged(UserServiceInterface $userService)
{
$user = $this->getAndLogUserByCookie($userService);
if ($user) {
$this->refreshRememberCookie($user, false);
return true;
} else {
return false;
}
} | [
"public",
"function",
"isLogged",
"(",
"UserServiceInterface",
"$",
"userService",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getAndLogUserByCookie",
"(",
"$",
"userService",
")",
";",
"if",
"(",
"$",
"user",
")",
"{",
"$",
"this",
"->",
"refreshRememberCookie",
"(",
"$",
"user",
",",
"false",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | (non-PHPdoc)
@see \Mouf\Security\UserService\IsLoggedProviderInterface::isLogged() | [
"(",
"non",
"-",
"PHPdoc",
")"
] | train | https://github.com/thecodingmachine/security.userservice/blob/39de12c32f324ab113441a69cd73cdb4b4673225/src/Mouf/Security/UserService/RememberMeAuthProvider.php#L71-L80 |
thecodingmachine/security.userservice | src/Mouf/Security/UserService/RememberMeAuthProvider.php | RememberMeAuthProvider.getUserId | public function getUserId(UserServiceInterface $userService)
{
$user = $this->getAndLogUserByCookie($userService);
return $user ? $user->getId() : null;
} | php | public function getUserId(UserServiceInterface $userService)
{
$user = $this->getAndLogUserByCookie($userService);
return $user ? $user->getId() : null;
} | [
"public",
"function",
"getUserId",
"(",
"UserServiceInterface",
"$",
"userService",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getAndLogUserByCookie",
"(",
"$",
"userService",
")",
";",
"return",
"$",
"user",
"?",
"$",
"user",
"->",
"getId",
"(",
")",
":",
"null",
";",
"}"
] | (non-PHPdoc)
@see \Mouf\Security\UserService\AuthenticationProviderInterface::getUserId() | [
"(",
"non",
"-",
"PHPdoc",
")"
] | train | https://github.com/thecodingmachine/security.userservice/blob/39de12c32f324ab113441a69cd73cdb4b4673225/src/Mouf/Security/UserService/RememberMeAuthProvider.php#L86-L90 |
thecodingmachine/security.userservice | src/Mouf/Security/UserService/RememberMeAuthProvider.php | RememberMeAuthProvider.getUserLogin | public function getUserLogin(UserServiceInterface $userService)
{
$user = $this->getAndLogUserByCookie($userService);
return $user ? $user->getLogin() : null;
} | php | public function getUserLogin(UserServiceInterface $userService)
{
$user = $this->getAndLogUserByCookie($userService);
return $user ? $user->getLogin() : null;
} | [
"public",
"function",
"getUserLogin",
"(",
"UserServiceInterface",
"$",
"userService",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getAndLogUserByCookie",
"(",
"$",
"userService",
")",
";",
"return",
"$",
"user",
"?",
"$",
"user",
"->",
"getLogin",
"(",
")",
":",
"null",
";",
"}"
] | (non-PHPdoc)
@see \Mouf\Security\UserService\AuthenticationProviderInterface::getUserLogin() | [
"(",
"non",
"-",
"PHPdoc",
")"
] | train | https://github.com/thecodingmachine/security.userservice/blob/39de12c32f324ab113441a69cd73cdb4b4673225/src/Mouf/Security/UserService/RememberMeAuthProvider.php#L96-L100 |
thecodingmachine/security.userservice | src/Mouf/Security/UserService/RememberMeAuthProvider.php | RememberMeAuthProvider.refreshRememberCookie | private function refreshRememberCookie(UserInterface $user, $gerenateToken = true)
{
$expire = is_numeric($this->expire) ? time() + 60 * $this>expire : strtotime("+" . $this->expire);
if (!$gerenateToken) {
$token = $_COOKIE[$this->cookieName];
} else {
$token = $this->randomPassword(32);
}
$this->rememberMeProvider->setUserRememberMeToken($user, $token);
setcookie($this->cookieName, $token, $expire, $this->url);
} | php | private function refreshRememberCookie(UserInterface $user, $gerenateToken = true)
{
$expire = is_numeric($this->expire) ? time() + 60 * $this>expire : strtotime("+" . $this->expire);
if (!$gerenateToken) {
$token = $_COOKIE[$this->cookieName];
} else {
$token = $this->randomPassword(32);
}
$this->rememberMeProvider->setUserRememberMeToken($user, $token);
setcookie($this->cookieName, $token, $expire, $this->url);
} | [
"private",
"function",
"refreshRememberCookie",
"(",
"UserInterface",
"$",
"user",
",",
"$",
"gerenateToken",
"=",
"true",
")",
"{",
"$",
"expire",
"=",
"is_numeric",
"(",
"$",
"this",
"->",
"expire",
")",
"?",
"time",
"(",
")",
"+",
"60",
"*",
"$",
"this",
">",
"expire",
":",
"strtotime",
"(",
"\"+\"",
".",
"$",
"this",
"->",
"expire",
")",
";",
"if",
"(",
"!",
"$",
"gerenateToken",
")",
"{",
"$",
"token",
"=",
"$",
"_COOKIE",
"[",
"$",
"this",
"->",
"cookieName",
"]",
";",
"}",
"else",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"randomPassword",
"(",
"32",
")",
";",
"}",
"$",
"this",
"->",
"rememberMeProvider",
"->",
"setUserRememberMeToken",
"(",
"$",
"user",
",",
"$",
"token",
")",
";",
"setcookie",
"(",
"$",
"this",
"->",
"cookieName",
",",
"$",
"token",
",",
"$",
"expire",
",",
"$",
"this",
"->",
"url",
")",
";",
"}"
] | Refresh the expiration time of the remember me cookie.
If $gerenateToken is passed to false, then the value of the cookie is not recaculated
@param UserInterface $user
@param bool $gerenateToken | [
"Refresh",
"the",
"expiration",
"time",
"of",
"the",
"remember",
"me",
"cookie",
".",
"If",
"$gerenateToken",
"is",
"passed",
"to",
"false",
"then",
"the",
"value",
"of",
"the",
"cookie",
"is",
"not",
"recaculated"
] | train | https://github.com/thecodingmachine/security.userservice/blob/39de12c32f324ab113441a69cd73cdb4b4673225/src/Mouf/Security/UserService/RememberMeAuthProvider.php#L140-L152 |
jakubkratina/larachartie | src/Formatters/PieChartFormatter.php | PieChartFormatter.format | public function format(DataTable $dataTable)
{
return array_merge(
[$this->columns($dataTable->columns())],
$this->rows($dataTable->rows())
);
} | php | public function format(DataTable $dataTable)
{
return array_merge(
[$this->columns($dataTable->columns())],
$this->rows($dataTable->rows())
);
} | [
"public",
"function",
"format",
"(",
"DataTable",
"$",
"dataTable",
")",
"{",
"return",
"array_merge",
"(",
"[",
"$",
"this",
"->",
"columns",
"(",
"$",
"dataTable",
"->",
"columns",
"(",
")",
")",
"]",
",",
"$",
"this",
"->",
"rows",
"(",
"$",
"dataTable",
"->",
"rows",
"(",
")",
")",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/jakubkratina/larachartie/blob/96c535650d61a2a6c1c1b12d374e5e59d33239f6/src/Formatters/PieChartFormatter.php#L20-L26 |
mothership-ec/composer | src/Composer/Command/ConfigCommand.php | ConfigCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
// Open file in editor
if ($input->getOption('editor')) {
$editor = escapeshellcmd(getenv('EDITOR'));
if (!$editor) {
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
$editor = 'notepad';
} else {
foreach (array('vim', 'vi', 'nano', 'pico', 'ed') as $candidate) {
if (exec('which '.$candidate)) {
$editor = $candidate;
break;
}
}
}
}
$file = $input->getOption('auth') ? $this->authConfigFile->getPath() : $this->configFile->getPath();
system($editor . ' ' . $file . (defined('PHP_WINDOWS_VERSION_BUILD') ? '' : ' > `tty`'));
return 0;
}
if (!$input->getOption('global')) {
$this->config->merge($this->configFile->read());
$this->config->merge(array('config' => $this->authConfigFile->exists() ? $this->authConfigFile->read() : array()));
}
// List the configuration of the file settings
if ($input->getOption('list')) {
$this->listConfiguration($this->config->all(), $this->config->raw(), $output);
return 0;
}
$settingKey = $input->getArgument('setting-key');
if (!$settingKey) {
return 0;
}
// If the user enters in a config variable, parse it and save to file
if (array() !== $input->getArgument('setting-value') && $input->getOption('unset')) {
throw new \RuntimeException('You can not combine a setting value with --unset');
}
// show the value if no value is provided
if (array() === $input->getArgument('setting-value') && !$input->getOption('unset')) {
$data = $this->config->all();
if (preg_match('/^repos?(?:itories)?(?:\.(.+))?/', $settingKey, $matches)) {
if (empty($matches[1])) {
$value = isset($data['repositories']) ? $data['repositories'] : array();
} else {
if (!isset($data['repositories'][$matches[1]])) {
throw new \InvalidArgumentException('There is no '.$matches[1].' repository defined');
}
$value = $data['repositories'][$matches[1]];
}
} elseif (strpos($settingKey, '.')) {
$bits = explode('.', $settingKey);
$data = $data['config'];
foreach ($bits as $bit) {
if (isset($data[$bit])) {
$data = $data[$bit];
} elseif (isset($data[implode('.', $bits)])) {
// last bit can contain domain names and such so try to join whatever is left if it exists
$data = $data[implode('.', $bits)];
break;
} else {
throw new \RuntimeException($settingKey.' is not defined');
}
array_shift($bits);
}
$value = $data;
} elseif (isset($data['config'][$settingKey])) {
$value = $this->config->get($settingKey, $input->getOption('absolute') ? 0 : Config::RELATIVE_PATHS);
} else {
throw new \RuntimeException($settingKey.' is not defined');
}
if (is_array($value)) {
$value = json_encode($value);
}
$this->getIO()->write($value);
return 0;
}
$values = $input->getArgument('setting-value'); // what the user is trying to add/change
$booleanValidator = function ($val) { return in_array($val, array('true', 'false', '1', '0'), true); };
$booleanNormalizer = function ($val) { return $val !== 'false' && (bool) $val; };
// handle config values
$uniqueConfigValues = array(
'process-timeout' => array('is_numeric', 'intval'),
'use-include-path' => array($booleanValidator, $booleanNormalizer),
'preferred-install' => array(
function ($val) { return in_array($val, array('auto', 'source', 'dist'), true); },
function ($val) { return $val; }
),
'store-auths' => array(
function ($val) { return in_array($val, array('true', 'false', 'prompt'), true); },
function ($val) {
if ('prompt' === $val) {
return 'prompt';
}
return $val !== 'false' && (bool) $val;
}
),
'notify-on-install' => array($booleanValidator, $booleanNormalizer),
'vendor-dir' => array('is_string', function ($val) { return $val; }),
'bin-dir' => array('is_string', function ($val) { return $val; }),
'cache-dir' => array('is_string', function ($val) { return $val; }),
'cache-files-dir' => array('is_string', function ($val) { return $val; }),
'cache-repo-dir' => array('is_string', function ($val) { return $val; }),
'cache-vcs-dir' => array('is_string', function ($val) { return $val; }),
'cache-ttl' => array('is_numeric', 'intval'),
'cache-files-ttl' => array('is_numeric', 'intval'),
'cache-files-maxsize' => array(
function ($val) { return preg_match('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $val) > 0; },
function ($val) { return $val; }
),
'discard-changes' => array(
function ($val) { return in_array($val, array('stash', 'true', 'false', '1', '0'), true); },
function ($val) {
if ('stash' === $val) {
return 'stash';
}
return $val !== 'false' && (bool) $val;
}
),
'autoloader-suffix' => array('is_string', function ($val) { return $val === 'null' ? null : $val; }),
'optimize-autoloader' => array($booleanValidator, $booleanNormalizer),
'classmap-authoritative' => array($booleanValidator, $booleanNormalizer),
'prepend-autoloader' => array($booleanValidator, $booleanNormalizer),
'github-expose-hostname' => array($booleanValidator, $booleanNormalizer),
);
$multiConfigValues = array(
'github-protocols' => array(
function ($vals) {
if (!is_array($vals)) {
return 'array expected';
}
foreach ($vals as $val) {
if (!in_array($val, array('git', 'https', 'ssh'))) {
return 'valid protocols include: git, https, ssh';
}
}
return true;
},
function ($vals) {
return $vals;
}
),
'github-domains' => array(
function ($vals) {
if (!is_array($vals)) {
return 'array expected';
}
return true;
},
function ($vals) {
return $vals;
}
),
);
foreach ($uniqueConfigValues as $name => $callbacks) {
if ($settingKey === $name) {
if ($input->getOption('unset')) {
return $this->configSource->removeConfigSetting($settingKey);
}
list($validator, $normalizer) = $callbacks;
if (1 !== count($values)) {
throw new \RuntimeException('You can only pass one value. Example: php composer.phar config process-timeout 300');
}
if (true !== $validation = $validator($values[0])) {
throw new \RuntimeException(sprintf(
'"%s" is an invalid value'.($validation ? ' ('.$validation.')' : ''),
$values[0]
));
}
return $this->configSource->addConfigSetting($settingKey, $normalizer($values[0]));
}
}
foreach ($multiConfigValues as $name => $callbacks) {
if ($settingKey === $name) {
if ($input->getOption('unset')) {
return $this->configSource->removeConfigSetting($settingKey);
}
list($validator, $normalizer) = $callbacks;
if (true !== $validation = $validator($values)) {
throw new \RuntimeException(sprintf(
'%s is an invalid value'.($validation ? ' ('.$validation.')' : ''),
json_encode($values)
));
}
return $this->configSource->addConfigSetting($settingKey, $normalizer($values));
}
}
// handle repositories
if (preg_match('/^repos?(?:itories)?\.(.+)/', $settingKey, $matches)) {
if ($input->getOption('unset')) {
return $this->configSource->removeRepository($matches[1]);
}
if (2 === count($values)) {
return $this->configSource->addRepository($matches[1], array(
'type' => $values[0],
'url' => $values[1],
));
}
if (1 === count($values)) {
$bool = strtolower($values[0]);
if (true === $booleanValidator($bool) && false === $booleanNormalizer($bool)) {
return $this->configSource->addRepository($matches[1], false);
}
}
throw new \RuntimeException('You must pass the type and a url. Example: php composer.phar config repositories.foo vcs http://bar.com');
}
// handle platform
if (preg_match('/^platform\.(.+)/', $settingKey, $matches)) {
if ($input->getOption('unset')) {
return $this->configSource->removeConfigSetting($settingKey);
}
return $this->configSource->addConfigSetting($settingKey, $values[0]);
}
// handle github-oauth
if (preg_match('/^(github-oauth|http-basic)\.(.+)/', $settingKey, $matches)) {
if ($input->getOption('unset')) {
$this->authConfigSource->removeConfigSetting($matches[1].'.'.$matches[2]);
$this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
return;
}
if ($matches[1] === 'github-oauth') {
if (1 !== count($values)) {
throw new \RuntimeException('Too many arguments, expected only one token');
}
$this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
$this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], $values[0]);
} elseif ($matches[1] === 'http-basic') {
if (2 !== count($values)) {
throw new \RuntimeException('Expected two arguments (username, password), got '.count($values));
}
$this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
$this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('username' => $values[0], 'password' => $values[1]));
}
return;
}
throw new \InvalidArgumentException('Setting '.$settingKey.' does not exist or is not supported by this command');
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
// Open file in editor
if ($input->getOption('editor')) {
$editor = escapeshellcmd(getenv('EDITOR'));
if (!$editor) {
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
$editor = 'notepad';
} else {
foreach (array('vim', 'vi', 'nano', 'pico', 'ed') as $candidate) {
if (exec('which '.$candidate)) {
$editor = $candidate;
break;
}
}
}
}
$file = $input->getOption('auth') ? $this->authConfigFile->getPath() : $this->configFile->getPath();
system($editor . ' ' . $file . (defined('PHP_WINDOWS_VERSION_BUILD') ? '' : ' > `tty`'));
return 0;
}
if (!$input->getOption('global')) {
$this->config->merge($this->configFile->read());
$this->config->merge(array('config' => $this->authConfigFile->exists() ? $this->authConfigFile->read() : array()));
}
// List the configuration of the file settings
if ($input->getOption('list')) {
$this->listConfiguration($this->config->all(), $this->config->raw(), $output);
return 0;
}
$settingKey = $input->getArgument('setting-key');
if (!$settingKey) {
return 0;
}
// If the user enters in a config variable, parse it and save to file
if (array() !== $input->getArgument('setting-value') && $input->getOption('unset')) {
throw new \RuntimeException('You can not combine a setting value with --unset');
}
// show the value if no value is provided
if (array() === $input->getArgument('setting-value') && !$input->getOption('unset')) {
$data = $this->config->all();
if (preg_match('/^repos?(?:itories)?(?:\.(.+))?/', $settingKey, $matches)) {
if (empty($matches[1])) {
$value = isset($data['repositories']) ? $data['repositories'] : array();
} else {
if (!isset($data['repositories'][$matches[1]])) {
throw new \InvalidArgumentException('There is no '.$matches[1].' repository defined');
}
$value = $data['repositories'][$matches[1]];
}
} elseif (strpos($settingKey, '.')) {
$bits = explode('.', $settingKey);
$data = $data['config'];
foreach ($bits as $bit) {
if (isset($data[$bit])) {
$data = $data[$bit];
} elseif (isset($data[implode('.', $bits)])) {
// last bit can contain domain names and such so try to join whatever is left if it exists
$data = $data[implode('.', $bits)];
break;
} else {
throw new \RuntimeException($settingKey.' is not defined');
}
array_shift($bits);
}
$value = $data;
} elseif (isset($data['config'][$settingKey])) {
$value = $this->config->get($settingKey, $input->getOption('absolute') ? 0 : Config::RELATIVE_PATHS);
} else {
throw new \RuntimeException($settingKey.' is not defined');
}
if (is_array($value)) {
$value = json_encode($value);
}
$this->getIO()->write($value);
return 0;
}
$values = $input->getArgument('setting-value'); // what the user is trying to add/change
$booleanValidator = function ($val) { return in_array($val, array('true', 'false', '1', '0'), true); };
$booleanNormalizer = function ($val) { return $val !== 'false' && (bool) $val; };
// handle config values
$uniqueConfigValues = array(
'process-timeout' => array('is_numeric', 'intval'),
'use-include-path' => array($booleanValidator, $booleanNormalizer),
'preferred-install' => array(
function ($val) { return in_array($val, array('auto', 'source', 'dist'), true); },
function ($val) { return $val; }
),
'store-auths' => array(
function ($val) { return in_array($val, array('true', 'false', 'prompt'), true); },
function ($val) {
if ('prompt' === $val) {
return 'prompt';
}
return $val !== 'false' && (bool) $val;
}
),
'notify-on-install' => array($booleanValidator, $booleanNormalizer),
'vendor-dir' => array('is_string', function ($val) { return $val; }),
'bin-dir' => array('is_string', function ($val) { return $val; }),
'cache-dir' => array('is_string', function ($val) { return $val; }),
'cache-files-dir' => array('is_string', function ($val) { return $val; }),
'cache-repo-dir' => array('is_string', function ($val) { return $val; }),
'cache-vcs-dir' => array('is_string', function ($val) { return $val; }),
'cache-ttl' => array('is_numeric', 'intval'),
'cache-files-ttl' => array('is_numeric', 'intval'),
'cache-files-maxsize' => array(
function ($val) { return preg_match('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $val) > 0; },
function ($val) { return $val; }
),
'discard-changes' => array(
function ($val) { return in_array($val, array('stash', 'true', 'false', '1', '0'), true); },
function ($val) {
if ('stash' === $val) {
return 'stash';
}
return $val !== 'false' && (bool) $val;
}
),
'autoloader-suffix' => array('is_string', function ($val) { return $val === 'null' ? null : $val; }),
'optimize-autoloader' => array($booleanValidator, $booleanNormalizer),
'classmap-authoritative' => array($booleanValidator, $booleanNormalizer),
'prepend-autoloader' => array($booleanValidator, $booleanNormalizer),
'github-expose-hostname' => array($booleanValidator, $booleanNormalizer),
);
$multiConfigValues = array(
'github-protocols' => array(
function ($vals) {
if (!is_array($vals)) {
return 'array expected';
}
foreach ($vals as $val) {
if (!in_array($val, array('git', 'https', 'ssh'))) {
return 'valid protocols include: git, https, ssh';
}
}
return true;
},
function ($vals) {
return $vals;
}
),
'github-domains' => array(
function ($vals) {
if (!is_array($vals)) {
return 'array expected';
}
return true;
},
function ($vals) {
return $vals;
}
),
);
foreach ($uniqueConfigValues as $name => $callbacks) {
if ($settingKey === $name) {
if ($input->getOption('unset')) {
return $this->configSource->removeConfigSetting($settingKey);
}
list($validator, $normalizer) = $callbacks;
if (1 !== count($values)) {
throw new \RuntimeException('You can only pass one value. Example: php composer.phar config process-timeout 300');
}
if (true !== $validation = $validator($values[0])) {
throw new \RuntimeException(sprintf(
'"%s" is an invalid value'.($validation ? ' ('.$validation.')' : ''),
$values[0]
));
}
return $this->configSource->addConfigSetting($settingKey, $normalizer($values[0]));
}
}
foreach ($multiConfigValues as $name => $callbacks) {
if ($settingKey === $name) {
if ($input->getOption('unset')) {
return $this->configSource->removeConfigSetting($settingKey);
}
list($validator, $normalizer) = $callbacks;
if (true !== $validation = $validator($values)) {
throw new \RuntimeException(sprintf(
'%s is an invalid value'.($validation ? ' ('.$validation.')' : ''),
json_encode($values)
));
}
return $this->configSource->addConfigSetting($settingKey, $normalizer($values));
}
}
// handle repositories
if (preg_match('/^repos?(?:itories)?\.(.+)/', $settingKey, $matches)) {
if ($input->getOption('unset')) {
return $this->configSource->removeRepository($matches[1]);
}
if (2 === count($values)) {
return $this->configSource->addRepository($matches[1], array(
'type' => $values[0],
'url' => $values[1],
));
}
if (1 === count($values)) {
$bool = strtolower($values[0]);
if (true === $booleanValidator($bool) && false === $booleanNormalizer($bool)) {
return $this->configSource->addRepository($matches[1], false);
}
}
throw new \RuntimeException('You must pass the type and a url. Example: php composer.phar config repositories.foo vcs http://bar.com');
}
// handle platform
if (preg_match('/^platform\.(.+)/', $settingKey, $matches)) {
if ($input->getOption('unset')) {
return $this->configSource->removeConfigSetting($settingKey);
}
return $this->configSource->addConfigSetting($settingKey, $values[0]);
}
// handle github-oauth
if (preg_match('/^(github-oauth|http-basic)\.(.+)/', $settingKey, $matches)) {
if ($input->getOption('unset')) {
$this->authConfigSource->removeConfigSetting($matches[1].'.'.$matches[2]);
$this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
return;
}
if ($matches[1] === 'github-oauth') {
if (1 !== count($values)) {
throw new \RuntimeException('Too many arguments, expected only one token');
}
$this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
$this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], $values[0]);
} elseif ($matches[1] === 'http-basic') {
if (2 !== count($values)) {
throw new \RuntimeException('Expected two arguments (username, password), got '.count($values));
}
$this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
$this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('username' => $values[0], 'password' => $values[1]));
}
return;
}
throw new \InvalidArgumentException('Setting '.$settingKey.' does not exist or is not supported by this command');
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"// Open file in editor",
"if",
"(",
"$",
"input",
"->",
"getOption",
"(",
"'editor'",
")",
")",
"{",
"$",
"editor",
"=",
"escapeshellcmd",
"(",
"getenv",
"(",
"'EDITOR'",
")",
")",
";",
"if",
"(",
"!",
"$",
"editor",
")",
"{",
"if",
"(",
"defined",
"(",
"'PHP_WINDOWS_VERSION_BUILD'",
")",
")",
"{",
"$",
"editor",
"=",
"'notepad'",
";",
"}",
"else",
"{",
"foreach",
"(",
"array",
"(",
"'vim'",
",",
"'vi'",
",",
"'nano'",
",",
"'pico'",
",",
"'ed'",
")",
"as",
"$",
"candidate",
")",
"{",
"if",
"(",
"exec",
"(",
"'which '",
".",
"$",
"candidate",
")",
")",
"{",
"$",
"editor",
"=",
"$",
"candidate",
";",
"break",
";",
"}",
"}",
"}",
"}",
"$",
"file",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'auth'",
")",
"?",
"$",
"this",
"->",
"authConfigFile",
"->",
"getPath",
"(",
")",
":",
"$",
"this",
"->",
"configFile",
"->",
"getPath",
"(",
")",
";",
"system",
"(",
"$",
"editor",
".",
"' '",
".",
"$",
"file",
".",
"(",
"defined",
"(",
"'PHP_WINDOWS_VERSION_BUILD'",
")",
"?",
"''",
":",
"' > `tty`'",
")",
")",
";",
"return",
"0",
";",
"}",
"if",
"(",
"!",
"$",
"input",
"->",
"getOption",
"(",
"'global'",
")",
")",
"{",
"$",
"this",
"->",
"config",
"->",
"merge",
"(",
"$",
"this",
"->",
"configFile",
"->",
"read",
"(",
")",
")",
";",
"$",
"this",
"->",
"config",
"->",
"merge",
"(",
"array",
"(",
"'config'",
"=>",
"$",
"this",
"->",
"authConfigFile",
"->",
"exists",
"(",
")",
"?",
"$",
"this",
"->",
"authConfigFile",
"->",
"read",
"(",
")",
":",
"array",
"(",
")",
")",
")",
";",
"}",
"// List the configuration of the file settings",
"if",
"(",
"$",
"input",
"->",
"getOption",
"(",
"'list'",
")",
")",
"{",
"$",
"this",
"->",
"listConfiguration",
"(",
"$",
"this",
"->",
"config",
"->",
"all",
"(",
")",
",",
"$",
"this",
"->",
"config",
"->",
"raw",
"(",
")",
",",
"$",
"output",
")",
";",
"return",
"0",
";",
"}",
"$",
"settingKey",
"=",
"$",
"input",
"->",
"getArgument",
"(",
"'setting-key'",
")",
";",
"if",
"(",
"!",
"$",
"settingKey",
")",
"{",
"return",
"0",
";",
"}",
"// If the user enters in a config variable, parse it and save to file",
"if",
"(",
"array",
"(",
")",
"!==",
"$",
"input",
"->",
"getArgument",
"(",
"'setting-value'",
")",
"&&",
"$",
"input",
"->",
"getOption",
"(",
"'unset'",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'You can not combine a setting value with --unset'",
")",
";",
"}",
"// show the value if no value is provided",
"if",
"(",
"array",
"(",
")",
"===",
"$",
"input",
"->",
"getArgument",
"(",
"'setting-value'",
")",
"&&",
"!",
"$",
"input",
"->",
"getOption",
"(",
"'unset'",
")",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"config",
"->",
"all",
"(",
")",
";",
"if",
"(",
"preg_match",
"(",
"'/^repos?(?:itories)?(?:\\.(.+))?/'",
",",
"$",
"settingKey",
",",
"$",
"matches",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
")",
"{",
"$",
"value",
"=",
"isset",
"(",
"$",
"data",
"[",
"'repositories'",
"]",
")",
"?",
"$",
"data",
"[",
"'repositories'",
"]",
":",
"array",
"(",
")",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"'repositories'",
"]",
"[",
"$",
"matches",
"[",
"1",
"]",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'There is no '",
".",
"$",
"matches",
"[",
"1",
"]",
".",
"' repository defined'",
")",
";",
"}",
"$",
"value",
"=",
"$",
"data",
"[",
"'repositories'",
"]",
"[",
"$",
"matches",
"[",
"1",
"]",
"]",
";",
"}",
"}",
"elseif",
"(",
"strpos",
"(",
"$",
"settingKey",
",",
"'.'",
")",
")",
"{",
"$",
"bits",
"=",
"explode",
"(",
"'.'",
",",
"$",
"settingKey",
")",
";",
"$",
"data",
"=",
"$",
"data",
"[",
"'config'",
"]",
";",
"foreach",
"(",
"$",
"bits",
"as",
"$",
"bit",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"$",
"bit",
"]",
")",
")",
"{",
"$",
"data",
"=",
"$",
"data",
"[",
"$",
"bit",
"]",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"data",
"[",
"implode",
"(",
"'.'",
",",
"$",
"bits",
")",
"]",
")",
")",
"{",
"// last bit can contain domain names and such so try to join whatever is left if it exists",
"$",
"data",
"=",
"$",
"data",
"[",
"implode",
"(",
"'.'",
",",
"$",
"bits",
")",
"]",
";",
"break",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"$",
"settingKey",
".",
"' is not defined'",
")",
";",
"}",
"array_shift",
"(",
"$",
"bits",
")",
";",
"}",
"$",
"value",
"=",
"$",
"data",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"data",
"[",
"'config'",
"]",
"[",
"$",
"settingKey",
"]",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"$",
"settingKey",
",",
"$",
"input",
"->",
"getOption",
"(",
"'absolute'",
")",
"?",
"0",
":",
"Config",
"::",
"RELATIVE_PATHS",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"$",
"settingKey",
".",
"' is not defined'",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"json_encode",
"(",
"$",
"value",
")",
";",
"}",
"$",
"this",
"->",
"getIO",
"(",
")",
"->",
"write",
"(",
"$",
"value",
")",
";",
"return",
"0",
";",
"}",
"$",
"values",
"=",
"$",
"input",
"->",
"getArgument",
"(",
"'setting-value'",
")",
";",
"// what the user is trying to add/change",
"$",
"booleanValidator",
"=",
"function",
"(",
"$",
"val",
")",
"{",
"return",
"in_array",
"(",
"$",
"val",
",",
"array",
"(",
"'true'",
",",
"'false'",
",",
"'1'",
",",
"'0'",
")",
",",
"true",
")",
";",
"}",
";",
"$",
"booleanNormalizer",
"=",
"function",
"(",
"$",
"val",
")",
"{",
"return",
"$",
"val",
"!==",
"'false'",
"&&",
"(",
"bool",
")",
"$",
"val",
";",
"}",
";",
"// handle config values",
"$",
"uniqueConfigValues",
"=",
"array",
"(",
"'process-timeout'",
"=>",
"array",
"(",
"'is_numeric'",
",",
"'intval'",
")",
",",
"'use-include-path'",
"=>",
"array",
"(",
"$",
"booleanValidator",
",",
"$",
"booleanNormalizer",
")",
",",
"'preferred-install'",
"=>",
"array",
"(",
"function",
"(",
"$",
"val",
")",
"{",
"return",
"in_array",
"(",
"$",
"val",
",",
"array",
"(",
"'auto'",
",",
"'source'",
",",
"'dist'",
")",
",",
"true",
")",
";",
"}",
",",
"function",
"(",
"$",
"val",
")",
"{",
"return",
"$",
"val",
";",
"}",
")",
",",
"'store-auths'",
"=>",
"array",
"(",
"function",
"(",
"$",
"val",
")",
"{",
"return",
"in_array",
"(",
"$",
"val",
",",
"array",
"(",
"'true'",
",",
"'false'",
",",
"'prompt'",
")",
",",
"true",
")",
";",
"}",
",",
"function",
"(",
"$",
"val",
")",
"{",
"if",
"(",
"'prompt'",
"===",
"$",
"val",
")",
"{",
"return",
"'prompt'",
";",
"}",
"return",
"$",
"val",
"!==",
"'false'",
"&&",
"(",
"bool",
")",
"$",
"val",
";",
"}",
")",
",",
"'notify-on-install'",
"=>",
"array",
"(",
"$",
"booleanValidator",
",",
"$",
"booleanNormalizer",
")",
",",
"'vendor-dir'",
"=>",
"array",
"(",
"'is_string'",
",",
"function",
"(",
"$",
"val",
")",
"{",
"return",
"$",
"val",
";",
"}",
")",
",",
"'bin-dir'",
"=>",
"array",
"(",
"'is_string'",
",",
"function",
"(",
"$",
"val",
")",
"{",
"return",
"$",
"val",
";",
"}",
")",
",",
"'cache-dir'",
"=>",
"array",
"(",
"'is_string'",
",",
"function",
"(",
"$",
"val",
")",
"{",
"return",
"$",
"val",
";",
"}",
")",
",",
"'cache-files-dir'",
"=>",
"array",
"(",
"'is_string'",
",",
"function",
"(",
"$",
"val",
")",
"{",
"return",
"$",
"val",
";",
"}",
")",
",",
"'cache-repo-dir'",
"=>",
"array",
"(",
"'is_string'",
",",
"function",
"(",
"$",
"val",
")",
"{",
"return",
"$",
"val",
";",
"}",
")",
",",
"'cache-vcs-dir'",
"=>",
"array",
"(",
"'is_string'",
",",
"function",
"(",
"$",
"val",
")",
"{",
"return",
"$",
"val",
";",
"}",
")",
",",
"'cache-ttl'",
"=>",
"array",
"(",
"'is_numeric'",
",",
"'intval'",
")",
",",
"'cache-files-ttl'",
"=>",
"array",
"(",
"'is_numeric'",
",",
"'intval'",
")",
",",
"'cache-files-maxsize'",
"=>",
"array",
"(",
"function",
"(",
"$",
"val",
")",
"{",
"return",
"preg_match",
"(",
"'/^\\s*([0-9.]+)\\s*(?:([kmg])(?:i?b)?)?\\s*$/i'",
",",
"$",
"val",
")",
">",
"0",
";",
"}",
",",
"function",
"(",
"$",
"val",
")",
"{",
"return",
"$",
"val",
";",
"}",
")",
",",
"'discard-changes'",
"=>",
"array",
"(",
"function",
"(",
"$",
"val",
")",
"{",
"return",
"in_array",
"(",
"$",
"val",
",",
"array",
"(",
"'stash'",
",",
"'true'",
",",
"'false'",
",",
"'1'",
",",
"'0'",
")",
",",
"true",
")",
";",
"}",
",",
"function",
"(",
"$",
"val",
")",
"{",
"if",
"(",
"'stash'",
"===",
"$",
"val",
")",
"{",
"return",
"'stash'",
";",
"}",
"return",
"$",
"val",
"!==",
"'false'",
"&&",
"(",
"bool",
")",
"$",
"val",
";",
"}",
")",
",",
"'autoloader-suffix'",
"=>",
"array",
"(",
"'is_string'",
",",
"function",
"(",
"$",
"val",
")",
"{",
"return",
"$",
"val",
"===",
"'null'",
"?",
"null",
":",
"$",
"val",
";",
"}",
")",
",",
"'optimize-autoloader'",
"=>",
"array",
"(",
"$",
"booleanValidator",
",",
"$",
"booleanNormalizer",
")",
",",
"'classmap-authoritative'",
"=>",
"array",
"(",
"$",
"booleanValidator",
",",
"$",
"booleanNormalizer",
")",
",",
"'prepend-autoloader'",
"=>",
"array",
"(",
"$",
"booleanValidator",
",",
"$",
"booleanNormalizer",
")",
",",
"'github-expose-hostname'",
"=>",
"array",
"(",
"$",
"booleanValidator",
",",
"$",
"booleanNormalizer",
")",
",",
")",
";",
"$",
"multiConfigValues",
"=",
"array",
"(",
"'github-protocols'",
"=>",
"array",
"(",
"function",
"(",
"$",
"vals",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"vals",
")",
")",
"{",
"return",
"'array expected'",
";",
"}",
"foreach",
"(",
"$",
"vals",
"as",
"$",
"val",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"val",
",",
"array",
"(",
"'git'",
",",
"'https'",
",",
"'ssh'",
")",
")",
")",
"{",
"return",
"'valid protocols include: git, https, ssh'",
";",
"}",
"}",
"return",
"true",
";",
"}",
",",
"function",
"(",
"$",
"vals",
")",
"{",
"return",
"$",
"vals",
";",
"}",
")",
",",
"'github-domains'",
"=>",
"array",
"(",
"function",
"(",
"$",
"vals",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"vals",
")",
")",
"{",
"return",
"'array expected'",
";",
"}",
"return",
"true",
";",
"}",
",",
"function",
"(",
"$",
"vals",
")",
"{",
"return",
"$",
"vals",
";",
"}",
")",
",",
")",
";",
"foreach",
"(",
"$",
"uniqueConfigValues",
"as",
"$",
"name",
"=>",
"$",
"callbacks",
")",
"{",
"if",
"(",
"$",
"settingKey",
"===",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"input",
"->",
"getOption",
"(",
"'unset'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"configSource",
"->",
"removeConfigSetting",
"(",
"$",
"settingKey",
")",
";",
"}",
"list",
"(",
"$",
"validator",
",",
"$",
"normalizer",
")",
"=",
"$",
"callbacks",
";",
"if",
"(",
"1",
"!==",
"count",
"(",
"$",
"values",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'You can only pass one value. Example: php composer.phar config process-timeout 300'",
")",
";",
"}",
"if",
"(",
"true",
"!==",
"$",
"validation",
"=",
"$",
"validator",
"(",
"$",
"values",
"[",
"0",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'\"%s\" is an invalid value'",
".",
"(",
"$",
"validation",
"?",
"' ('",
".",
"$",
"validation",
".",
"')'",
":",
"''",
")",
",",
"$",
"values",
"[",
"0",
"]",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"configSource",
"->",
"addConfigSetting",
"(",
"$",
"settingKey",
",",
"$",
"normalizer",
"(",
"$",
"values",
"[",
"0",
"]",
")",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"multiConfigValues",
"as",
"$",
"name",
"=>",
"$",
"callbacks",
")",
"{",
"if",
"(",
"$",
"settingKey",
"===",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"input",
"->",
"getOption",
"(",
"'unset'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"configSource",
"->",
"removeConfigSetting",
"(",
"$",
"settingKey",
")",
";",
"}",
"list",
"(",
"$",
"validator",
",",
"$",
"normalizer",
")",
"=",
"$",
"callbacks",
";",
"if",
"(",
"true",
"!==",
"$",
"validation",
"=",
"$",
"validator",
"(",
"$",
"values",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'%s is an invalid value'",
".",
"(",
"$",
"validation",
"?",
"' ('",
".",
"$",
"validation",
".",
"')'",
":",
"''",
")",
",",
"json_encode",
"(",
"$",
"values",
")",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"configSource",
"->",
"addConfigSetting",
"(",
"$",
"settingKey",
",",
"$",
"normalizer",
"(",
"$",
"values",
")",
")",
";",
"}",
"}",
"// handle repositories",
"if",
"(",
"preg_match",
"(",
"'/^repos?(?:itories)?\\.(.+)/'",
",",
"$",
"settingKey",
",",
"$",
"matches",
")",
")",
"{",
"if",
"(",
"$",
"input",
"->",
"getOption",
"(",
"'unset'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"configSource",
"->",
"removeRepository",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"}",
"if",
"(",
"2",
"===",
"count",
"(",
"$",
"values",
")",
")",
"{",
"return",
"$",
"this",
"->",
"configSource",
"->",
"addRepository",
"(",
"$",
"matches",
"[",
"1",
"]",
",",
"array",
"(",
"'type'",
"=>",
"$",
"values",
"[",
"0",
"]",
",",
"'url'",
"=>",
"$",
"values",
"[",
"1",
"]",
",",
")",
")",
";",
"}",
"if",
"(",
"1",
"===",
"count",
"(",
"$",
"values",
")",
")",
"{",
"$",
"bool",
"=",
"strtolower",
"(",
"$",
"values",
"[",
"0",
"]",
")",
";",
"if",
"(",
"true",
"===",
"$",
"booleanValidator",
"(",
"$",
"bool",
")",
"&&",
"false",
"===",
"$",
"booleanNormalizer",
"(",
"$",
"bool",
")",
")",
"{",
"return",
"$",
"this",
"->",
"configSource",
"->",
"addRepository",
"(",
"$",
"matches",
"[",
"1",
"]",
",",
"false",
")",
";",
"}",
"}",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'You must pass the type and a url. Example: php composer.phar config repositories.foo vcs http://bar.com'",
")",
";",
"}",
"// handle platform",
"if",
"(",
"preg_match",
"(",
"'/^platform\\.(.+)/'",
",",
"$",
"settingKey",
",",
"$",
"matches",
")",
")",
"{",
"if",
"(",
"$",
"input",
"->",
"getOption",
"(",
"'unset'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"configSource",
"->",
"removeConfigSetting",
"(",
"$",
"settingKey",
")",
";",
"}",
"return",
"$",
"this",
"->",
"configSource",
"->",
"addConfigSetting",
"(",
"$",
"settingKey",
",",
"$",
"values",
"[",
"0",
"]",
")",
";",
"}",
"// handle github-oauth",
"if",
"(",
"preg_match",
"(",
"'/^(github-oauth|http-basic)\\.(.+)/'",
",",
"$",
"settingKey",
",",
"$",
"matches",
")",
")",
"{",
"if",
"(",
"$",
"input",
"->",
"getOption",
"(",
"'unset'",
")",
")",
"{",
"$",
"this",
"->",
"authConfigSource",
"->",
"removeConfigSetting",
"(",
"$",
"matches",
"[",
"1",
"]",
".",
"'.'",
".",
"$",
"matches",
"[",
"2",
"]",
")",
";",
"$",
"this",
"->",
"configSource",
"->",
"removeConfigSetting",
"(",
"$",
"matches",
"[",
"1",
"]",
".",
"'.'",
".",
"$",
"matches",
"[",
"2",
"]",
")",
";",
"return",
";",
"}",
"if",
"(",
"$",
"matches",
"[",
"1",
"]",
"===",
"'github-oauth'",
")",
"{",
"if",
"(",
"1",
"!==",
"count",
"(",
"$",
"values",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Too many arguments, expected only one token'",
")",
";",
"}",
"$",
"this",
"->",
"configSource",
"->",
"removeConfigSetting",
"(",
"$",
"matches",
"[",
"1",
"]",
".",
"'.'",
".",
"$",
"matches",
"[",
"2",
"]",
")",
";",
"$",
"this",
"->",
"authConfigSource",
"->",
"addConfigSetting",
"(",
"$",
"matches",
"[",
"1",
"]",
".",
"'.'",
".",
"$",
"matches",
"[",
"2",
"]",
",",
"$",
"values",
"[",
"0",
"]",
")",
";",
"}",
"elseif",
"(",
"$",
"matches",
"[",
"1",
"]",
"===",
"'http-basic'",
")",
"{",
"if",
"(",
"2",
"!==",
"count",
"(",
"$",
"values",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Expected two arguments (username, password), got '",
".",
"count",
"(",
"$",
"values",
")",
")",
";",
"}",
"$",
"this",
"->",
"configSource",
"->",
"removeConfigSetting",
"(",
"$",
"matches",
"[",
"1",
"]",
".",
"'.'",
".",
"$",
"matches",
"[",
"2",
"]",
")",
";",
"$",
"this",
"->",
"authConfigSource",
"->",
"addConfigSetting",
"(",
"$",
"matches",
"[",
"1",
"]",
".",
"'.'",
".",
"$",
"matches",
"[",
"2",
"]",
",",
"array",
"(",
"'username'",
"=>",
"$",
"values",
"[",
"0",
"]",
",",
"'password'",
"=>",
"$",
"values",
"[",
"1",
"]",
")",
")",
";",
"}",
"return",
";",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Setting '",
".",
"$",
"settingKey",
".",
"' does not exist or is not supported by this command'",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Command/ConfigCommand.php#L179-L454 |
mothership-ec/composer | src/Composer/Command/ConfigCommand.php | ConfigCommand.listConfiguration | protected function listConfiguration(array $contents, array $rawContents, OutputInterface $output, $k = null)
{
$origK = $k;
foreach ($contents as $key => $value) {
if ($k === null && !in_array($key, array('config', 'repositories'))) {
continue;
}
$rawVal = isset($rawContents[$key]) ? $rawContents[$key] : null;
if (is_array($value) && (!is_numeric(key($value)) || ($key === 'repositories' && null === $k))) {
$k .= preg_replace('{^config\.}', '', $key . '.');
$this->listConfiguration($value, $rawVal, $output, $k);
if (substr_count($k, '.') > 1) {
$k = str_split($k, strrpos($k, '.', -2));
$k = $k[0] . '.';
} else {
$k = $origK;
}
continue;
}
if (is_array($value)) {
$value = array_map(function ($val) {
return is_array($val) ? json_encode($val) : $val;
}, $value);
$value = '['.implode(', ', $value).']';
}
if (is_bool($value)) {
$value = var_export($value, true);
}
if (is_string($rawVal) && $rawVal != $value) {
$this->getIO()->write('[<comment>' . $k . $key . '</comment>] <info>' . $rawVal . ' (' . $value . ')</info>');
} else {
$this->getIO()->write('[<comment>' . $k . $key . '</comment>] <info>' . $value . '</info>');
}
}
} | php | protected function listConfiguration(array $contents, array $rawContents, OutputInterface $output, $k = null)
{
$origK = $k;
foreach ($contents as $key => $value) {
if ($k === null && !in_array($key, array('config', 'repositories'))) {
continue;
}
$rawVal = isset($rawContents[$key]) ? $rawContents[$key] : null;
if (is_array($value) && (!is_numeric(key($value)) || ($key === 'repositories' && null === $k))) {
$k .= preg_replace('{^config\.}', '', $key . '.');
$this->listConfiguration($value, $rawVal, $output, $k);
if (substr_count($k, '.') > 1) {
$k = str_split($k, strrpos($k, '.', -2));
$k = $k[0] . '.';
} else {
$k = $origK;
}
continue;
}
if (is_array($value)) {
$value = array_map(function ($val) {
return is_array($val) ? json_encode($val) : $val;
}, $value);
$value = '['.implode(', ', $value).']';
}
if (is_bool($value)) {
$value = var_export($value, true);
}
if (is_string($rawVal) && $rawVal != $value) {
$this->getIO()->write('[<comment>' . $k . $key . '</comment>] <info>' . $rawVal . ' (' . $value . ')</info>');
} else {
$this->getIO()->write('[<comment>' . $k . $key . '</comment>] <info>' . $value . '</info>');
}
}
} | [
"protected",
"function",
"listConfiguration",
"(",
"array",
"$",
"contents",
",",
"array",
"$",
"rawContents",
",",
"OutputInterface",
"$",
"output",
",",
"$",
"k",
"=",
"null",
")",
"{",
"$",
"origK",
"=",
"$",
"k",
";",
"foreach",
"(",
"$",
"contents",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"k",
"===",
"null",
"&&",
"!",
"in_array",
"(",
"$",
"key",
",",
"array",
"(",
"'config'",
",",
"'repositories'",
")",
")",
")",
"{",
"continue",
";",
"}",
"$",
"rawVal",
"=",
"isset",
"(",
"$",
"rawContents",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"rawContents",
"[",
"$",
"key",
"]",
":",
"null",
";",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"&&",
"(",
"!",
"is_numeric",
"(",
"key",
"(",
"$",
"value",
")",
")",
"||",
"(",
"$",
"key",
"===",
"'repositories'",
"&&",
"null",
"===",
"$",
"k",
")",
")",
")",
"{",
"$",
"k",
".=",
"preg_replace",
"(",
"'{^config\\.}'",
",",
"''",
",",
"$",
"key",
".",
"'.'",
")",
";",
"$",
"this",
"->",
"listConfiguration",
"(",
"$",
"value",
",",
"$",
"rawVal",
",",
"$",
"output",
",",
"$",
"k",
")",
";",
"if",
"(",
"substr_count",
"(",
"$",
"k",
",",
"'.'",
")",
">",
"1",
")",
"{",
"$",
"k",
"=",
"str_split",
"(",
"$",
"k",
",",
"strrpos",
"(",
"$",
"k",
",",
"'.'",
",",
"-",
"2",
")",
")",
";",
"$",
"k",
"=",
"$",
"k",
"[",
"0",
"]",
".",
"'.'",
";",
"}",
"else",
"{",
"$",
"k",
"=",
"$",
"origK",
";",
"}",
"continue",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"array_map",
"(",
"function",
"(",
"$",
"val",
")",
"{",
"return",
"is_array",
"(",
"$",
"val",
")",
"?",
"json_encode",
"(",
"$",
"val",
")",
":",
"$",
"val",
";",
"}",
",",
"$",
"value",
")",
";",
"$",
"value",
"=",
"'['",
".",
"implode",
"(",
"', '",
",",
"$",
"value",
")",
".",
"']'",
";",
"}",
"if",
"(",
"is_bool",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"var_export",
"(",
"$",
"value",
",",
"true",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"rawVal",
")",
"&&",
"$",
"rawVal",
"!=",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"getIO",
"(",
")",
"->",
"write",
"(",
"'[<comment>'",
".",
"$",
"k",
".",
"$",
"key",
".",
"'</comment>] <info>'",
".",
"$",
"rawVal",
".",
"' ('",
".",
"$",
"value",
".",
"')</info>'",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"getIO",
"(",
")",
"->",
"write",
"(",
"'[<comment>'",
".",
"$",
"k",
".",
"$",
"key",
".",
"'</comment>] <info>'",
".",
"$",
"value",
".",
"'</info>'",
")",
";",
"}",
"}",
"}"
] | Display the contents of the file in a pretty formatted way
@param array $contents
@param array $rawContents
@param OutputInterface $output
@param string|null $k | [
"Display",
"the",
"contents",
"of",
"the",
"file",
"in",
"a",
"pretty",
"formatted",
"way"
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Command/ConfigCommand.php#L464-L506 |
prooph/link-monitor | src/Controller/Factory/ProcessViewControllerFactory.php | ProcessViewControllerFactory.createService | public function createService(ServiceLocatorInterface $serviceLocator)
{
return new ProcessViewController(
$serviceLocator->getServiceLocator()->get('prooph.link.monitor.process_logger'),
$serviceLocator->getServiceLocator()->get('prooph.link.monitor.process_stream_reader'),
ScriptLocation::fromPath(Definition::getScriptsDir()),
$serviceLocator->getServiceLocator()->get('prooph.link.app.location_translator')
);
} | php | public function createService(ServiceLocatorInterface $serviceLocator)
{
return new ProcessViewController(
$serviceLocator->getServiceLocator()->get('prooph.link.monitor.process_logger'),
$serviceLocator->getServiceLocator()->get('prooph.link.monitor.process_stream_reader'),
ScriptLocation::fromPath(Definition::getScriptsDir()),
$serviceLocator->getServiceLocator()->get('prooph.link.app.location_translator')
);
} | [
"public",
"function",
"createService",
"(",
"ServiceLocatorInterface",
"$",
"serviceLocator",
")",
"{",
"return",
"new",
"ProcessViewController",
"(",
"$",
"serviceLocator",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'prooph.link.monitor.process_logger'",
")",
",",
"$",
"serviceLocator",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'prooph.link.monitor.process_stream_reader'",
")",
",",
"ScriptLocation",
"::",
"fromPath",
"(",
"Definition",
"::",
"getScriptsDir",
"(",
")",
")",
",",
"$",
"serviceLocator",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'prooph.link.app.location_translator'",
")",
")",
";",
"}"
] | Create service
@param ServiceLocatorInterface $serviceLocator
@return mixed | [
"Create",
"service"
] | train | https://github.com/prooph/link-monitor/blob/5dd12a4bda48eb05471181bf4dab43938cf39df8/src/Controller/Factory/ProcessViewControllerFactory.php#L34-L42 |
ajgarlag/AjglCsv | src/Csv.php | Csv.createReader | public function createReader($filePath, $delimiter = ReaderInterface::DELIMITER_DEFAULT, $fileCharset = ReaderInterface::CHARSET_DEFAULT, $mode = 'r', $type = null)
{
if (null === $type) {
$type = $this->getDefaultReaderType();
}
return $this->getReaderFactory()->createReader($type, $filePath, $delimiter, $fileCharset, $mode);
} | php | public function createReader($filePath, $delimiter = ReaderInterface::DELIMITER_DEFAULT, $fileCharset = ReaderInterface::CHARSET_DEFAULT, $mode = 'r', $type = null)
{
if (null === $type) {
$type = $this->getDefaultReaderType();
}
return $this->getReaderFactory()->createReader($type, $filePath, $delimiter, $fileCharset, $mode);
} | [
"public",
"function",
"createReader",
"(",
"$",
"filePath",
",",
"$",
"delimiter",
"=",
"ReaderInterface",
"::",
"DELIMITER_DEFAULT",
",",
"$",
"fileCharset",
"=",
"ReaderInterface",
"::",
"CHARSET_DEFAULT",
",",
"$",
"mode",
"=",
"'r'",
",",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"type",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"getDefaultReaderType",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getReaderFactory",
"(",
")",
"->",
"createReader",
"(",
"$",
"type",
",",
"$",
"filePath",
",",
"$",
"delimiter",
",",
"$",
"fileCharset",
",",
"$",
"mode",
")",
";",
"}"
] | @param string $filePath
@param string $delimiter
@param string $fileCharset
@param string $mode
@param string $type
@return ReaderInterface | [
"@param",
"string",
"$filePath",
"@param",
"string",
"$delimiter",
"@param",
"string",
"$fileCharset",
"@param",
"string",
"$mode",
"@param",
"string",
"$type"
] | train | https://github.com/ajgarlag/AjglCsv/blob/28872f58b9ef864893cac6faddfcb1229c2c2047/src/Csv.php#L138-L145 |
ajgarlag/AjglCsv | src/Csv.php | Csv.createWriter | public function createWriter($filePath, $delimiter = WriterInterface::DELIMITER_DEFAULT, $fileCharset = WriterInterface::CHARSET_DEFAULT, $mode = 'w', $type = null)
{
if (null === $type) {
$type = $this->getDefaultWriterType();
}
return $this->getWriterFactory()->createWriter($type, $filePath, $delimiter, $fileCharset, $mode);
} | php | public function createWriter($filePath, $delimiter = WriterInterface::DELIMITER_DEFAULT, $fileCharset = WriterInterface::CHARSET_DEFAULT, $mode = 'w', $type = null)
{
if (null === $type) {
$type = $this->getDefaultWriterType();
}
return $this->getWriterFactory()->createWriter($type, $filePath, $delimiter, $fileCharset, $mode);
} | [
"public",
"function",
"createWriter",
"(",
"$",
"filePath",
",",
"$",
"delimiter",
"=",
"WriterInterface",
"::",
"DELIMITER_DEFAULT",
",",
"$",
"fileCharset",
"=",
"WriterInterface",
"::",
"CHARSET_DEFAULT",
",",
"$",
"mode",
"=",
"'w'",
",",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"type",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"getDefaultWriterType",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getWriterFactory",
"(",
")",
"->",
"createWriter",
"(",
"$",
"type",
",",
"$",
"filePath",
",",
"$",
"delimiter",
",",
"$",
"fileCharset",
",",
"$",
"mode",
")",
";",
"}"
] | @param string $filePath
@param string $delimiter
@param string $fileCharset
@param string $mode
@param string $type
@return WriterInterface | [
"@param",
"string",
"$filePath",
"@param",
"string",
"$delimiter",
"@param",
"string",
"$fileCharset",
"@param",
"string",
"$mode",
"@param",
"string",
"$type"
] | train | https://github.com/ajgarlag/AjglCsv/blob/28872f58b9ef864893cac6faddfcb1229c2c2047/src/Csv.php#L156-L163 |
surebert/surebert-framework | src/sb/Image.php | Image.set | public function set($orig, $dest='')
{
if(!empty($dest)){
copy($orig, $dest);
$orig = $dest;
}
$this->path = $orig;
$this->getInfo();
} | php | public function set($orig, $dest='')
{
if(!empty($dest)){
copy($orig, $dest);
$orig = $dest;
}
$this->path = $orig;
$this->getInfo();
} | [
"public",
"function",
"set",
"(",
"$",
"orig",
",",
"$",
"dest",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"dest",
")",
")",
"{",
"copy",
"(",
"$",
"orig",
",",
"$",
"dest",
")",
";",
"$",
"orig",
"=",
"$",
"dest",
";",
"}",
"$",
"this",
"->",
"path",
"=",
"$",
"orig",
";",
"$",
"this",
"->",
"getInfo",
"(",
")",
";",
"}"
] | Sets the image being edited
@param string $orig the file path to the image being edited
@param string $dest optional, the file path to name the edited file should be saved as, without this the original file gets saved over with the edited version | [
"Sets",
"the",
"image",
"being",
"edited"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Image.php#L97-L107 |
surebert/surebert-framework | src/sb/Image.php | Image.getInfo | public function getInfo()
{
$file_info = @getimagesize($this->path);
//define the original width of the image
$this->width['orig'] = $file_info['0'];
//define the original height of the image
$this->height['orig'] = $file_info['1'];
//image type //1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF, 15 = WBMP, 16 = XBM
switch ($file_info[2])
{
case "1":
$this->type = "gif";
break;
case "2":
$this->type = "jpg";
break;
case "3":
$this->type = "png";
break;
}
//////////////////////////
$this->original = imagecreatefromstring(file_get_contents($this->path));
} | php | public function getInfo()
{
$file_info = @getimagesize($this->path);
//define the original width of the image
$this->width['orig'] = $file_info['0'];
//define the original height of the image
$this->height['orig'] = $file_info['1'];
//image type //1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF, 15 = WBMP, 16 = XBM
switch ($file_info[2])
{
case "1":
$this->type = "gif";
break;
case "2":
$this->type = "jpg";
break;
case "3":
$this->type = "png";
break;
}
//////////////////////////
$this->original = imagecreatefromstring(file_get_contents($this->path));
} | [
"public",
"function",
"getInfo",
"(",
")",
"{",
"$",
"file_info",
"=",
"@",
"getimagesize",
"(",
"$",
"this",
"->",
"path",
")",
";",
"//define the original width of the image",
"$",
"this",
"->",
"width",
"[",
"'orig'",
"]",
"=",
"$",
"file_info",
"[",
"'0'",
"]",
";",
"//define the original height of the image",
"$",
"this",
"->",
"height",
"[",
"'orig'",
"]",
"=",
"$",
"file_info",
"[",
"'1'",
"]",
";",
"//image type //1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF, 15 = WBMP, 16 = XBM",
"switch",
"(",
"$",
"file_info",
"[",
"2",
"]",
")",
"{",
"case",
"\"1\"",
":",
"$",
"this",
"->",
"type",
"=",
"\"gif\"",
";",
"break",
";",
"case",
"\"2\"",
":",
"$",
"this",
"->",
"type",
"=",
"\"jpg\"",
";",
"break",
";",
"case",
"\"3\"",
":",
"$",
"this",
"->",
"type",
"=",
"\"png\"",
";",
"break",
";",
"}",
"//////////////////////////",
"$",
"this",
"->",
"original",
"=",
"imagecreatefromstring",
"(",
"file_get_contents",
"(",
"$",
"this",
"->",
"path",
")",
")",
";",
"}"
] | Gets the image file type, width, and height | [
"Gets",
"the",
"image",
"file",
"type",
"width",
"and",
"height"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Image.php#L113-L144 |
surebert/surebert-framework | src/sb/Image.php | Image.resize | public function resize($width, $height)
{
//if the width is not specified, make it relative to the height
if($width == -1){
$this->width['dest'] = ($height * $this->width['orig']) / $this->height['orig'];
$this->height['dest'] = $height;
//if the height is not specified, make it relative to the width
} elseif ($height == -1){
$this->width['dest'] = $width;
$this->height['dest'] = ($width * $this->height['orig']) / $this->width['orig'];
} else {
$this->width['dest'] = $width;
$this->height['dest'] = $height;
}
//set resize code depending on the type of image it is
switch ($this->type)
{
case "gif":
$this->edited = imagecreate($this->width['dest'], $this->height['dest']);
imagecopyresampled($this->edited, $this->original, 0, 0, 0, 0, $this->width['dest'], $this->height['dest'], $this->width['orig'], $this->height['orig']);
break;
case "jpg":
$this->edited = imagecreatetruecolor($this->width['dest'], $this->height['dest']);
imagecopyresampled($this->edited, $this->original, 0, 0, 0, 0, $this->width['dest'], $this->height['dest'], $this->width['orig'], $this->height['orig']);
break;
case "png":
$this->edited = imagecreatetruecolor ($this->width['dest'], $this->height['dest']);
//preserve the alpha if exists
imagealphablending($this->edited, false);
imagesavealpha($this->edited, true);
imagecopyresampled($this->edited, $this->original, 0, 0, 0, 0, $this->width['dest'], $this->height['dest'], $this->width['orig'], $this->height['orig']);
break;
}
} | php | public function resize($width, $height)
{
//if the width is not specified, make it relative to the height
if($width == -1){
$this->width['dest'] = ($height * $this->width['orig']) / $this->height['orig'];
$this->height['dest'] = $height;
//if the height is not specified, make it relative to the width
} elseif ($height == -1){
$this->width['dest'] = $width;
$this->height['dest'] = ($width * $this->height['orig']) / $this->width['orig'];
} else {
$this->width['dest'] = $width;
$this->height['dest'] = $height;
}
//set resize code depending on the type of image it is
switch ($this->type)
{
case "gif":
$this->edited = imagecreate($this->width['dest'], $this->height['dest']);
imagecopyresampled($this->edited, $this->original, 0, 0, 0, 0, $this->width['dest'], $this->height['dest'], $this->width['orig'], $this->height['orig']);
break;
case "jpg":
$this->edited = imagecreatetruecolor($this->width['dest'], $this->height['dest']);
imagecopyresampled($this->edited, $this->original, 0, 0, 0, 0, $this->width['dest'], $this->height['dest'], $this->width['orig'], $this->height['orig']);
break;
case "png":
$this->edited = imagecreatetruecolor ($this->width['dest'], $this->height['dest']);
//preserve the alpha if exists
imagealphablending($this->edited, false);
imagesavealpha($this->edited, true);
imagecopyresampled($this->edited, $this->original, 0, 0, 0, 0, $this->width['dest'], $this->height['dest'], $this->width['orig'], $this->height['orig']);
break;
}
} | [
"public",
"function",
"resize",
"(",
"$",
"width",
",",
"$",
"height",
")",
"{",
"//if the width is not specified, make it relative to the height",
"if",
"(",
"$",
"width",
"==",
"-",
"1",
")",
"{",
"$",
"this",
"->",
"width",
"[",
"'dest'",
"]",
"=",
"(",
"$",
"height",
"*",
"$",
"this",
"->",
"width",
"[",
"'orig'",
"]",
")",
"/",
"$",
"this",
"->",
"height",
"[",
"'orig'",
"]",
";",
"$",
"this",
"->",
"height",
"[",
"'dest'",
"]",
"=",
"$",
"height",
";",
"//if the height is not specified, make it relative to the width",
"}",
"elseif",
"(",
"$",
"height",
"==",
"-",
"1",
")",
"{",
"$",
"this",
"->",
"width",
"[",
"'dest'",
"]",
"=",
"$",
"width",
";",
"$",
"this",
"->",
"height",
"[",
"'dest'",
"]",
"=",
"(",
"$",
"width",
"*",
"$",
"this",
"->",
"height",
"[",
"'orig'",
"]",
")",
"/",
"$",
"this",
"->",
"width",
"[",
"'orig'",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"width",
"[",
"'dest'",
"]",
"=",
"$",
"width",
";",
"$",
"this",
"->",
"height",
"[",
"'dest'",
"]",
"=",
"$",
"height",
";",
"}",
"//set resize code depending on the type of image it is",
"switch",
"(",
"$",
"this",
"->",
"type",
")",
"{",
"case",
"\"gif\"",
":",
"$",
"this",
"->",
"edited",
"=",
"imagecreate",
"(",
"$",
"this",
"->",
"width",
"[",
"'dest'",
"]",
",",
"$",
"this",
"->",
"height",
"[",
"'dest'",
"]",
")",
";",
"imagecopyresampled",
"(",
"$",
"this",
"->",
"edited",
",",
"$",
"this",
"->",
"original",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"$",
"this",
"->",
"width",
"[",
"'dest'",
"]",
",",
"$",
"this",
"->",
"height",
"[",
"'dest'",
"]",
",",
"$",
"this",
"->",
"width",
"[",
"'orig'",
"]",
",",
"$",
"this",
"->",
"height",
"[",
"'orig'",
"]",
")",
";",
"break",
";",
"case",
"\"jpg\"",
":",
"$",
"this",
"->",
"edited",
"=",
"imagecreatetruecolor",
"(",
"$",
"this",
"->",
"width",
"[",
"'dest'",
"]",
",",
"$",
"this",
"->",
"height",
"[",
"'dest'",
"]",
")",
";",
"imagecopyresampled",
"(",
"$",
"this",
"->",
"edited",
",",
"$",
"this",
"->",
"original",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"$",
"this",
"->",
"width",
"[",
"'dest'",
"]",
",",
"$",
"this",
"->",
"height",
"[",
"'dest'",
"]",
",",
"$",
"this",
"->",
"width",
"[",
"'orig'",
"]",
",",
"$",
"this",
"->",
"height",
"[",
"'orig'",
"]",
")",
";",
"break",
";",
"case",
"\"png\"",
":",
"$",
"this",
"->",
"edited",
"=",
"imagecreatetruecolor",
"(",
"$",
"this",
"->",
"width",
"[",
"'dest'",
"]",
",",
"$",
"this",
"->",
"height",
"[",
"'dest'",
"]",
")",
";",
"//preserve the alpha if exists",
"imagealphablending",
"(",
"$",
"this",
"->",
"edited",
",",
"false",
")",
";",
"imagesavealpha",
"(",
"$",
"this",
"->",
"edited",
",",
"true",
")",
";",
"imagecopyresampled",
"(",
"$",
"this",
"->",
"edited",
",",
"$",
"this",
"->",
"original",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"$",
"this",
"->",
"width",
"[",
"'dest'",
"]",
",",
"$",
"this",
"->",
"height",
"[",
"'dest'",
"]",
",",
"$",
"this",
"->",
"width",
"[",
"'orig'",
"]",
",",
"$",
"this",
"->",
"height",
"[",
"'orig'",
"]",
")",
";",
"break",
";",
"}",
"}"
] | Resizes an the edited image to the specified width and height
@param int $width can be * to make it relative to a specified height
@param int $height can be * to make it relative to a specified width | [
"Resizes",
"an",
"the",
"edited",
"image",
"to",
"the",
"specified",
"width",
"and",
"height"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Image.php#L167-L219 |
surebert/surebert-framework | src/sb/Image.php | Image.toGrayscale | public function toGrayscale()
{
$this->getInfo();
$this->edited = imagecreate($this->width['orig'], $this->height['orig']);
//Creates the 256 color palette
for ($c=0;$c<256;$c++)
{
$palette[$c] = imagecolorallocate($this->edited,$c,$c,$c);
}
//Reads the origonal colors pixel by pixel
for ($y=0;$y<$this->height['orig'];$y++)
{
for ($x=0;$x<$this->width['orig'];$x++)
{
$rgb = imagecolorat($this->original,$x,$y);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
//This is where we actually use yiq to modify our rbg values, and then convert them to our grayscale palette
$gs = $this->colorToGray($r,$g,$b);
imagesetpixel($this->edited,$x,$y,$palette[$gs]);
}
}
} | php | public function toGrayscale()
{
$this->getInfo();
$this->edited = imagecreate($this->width['orig'], $this->height['orig']);
//Creates the 256 color palette
for ($c=0;$c<256;$c++)
{
$palette[$c] = imagecolorallocate($this->edited,$c,$c,$c);
}
//Reads the origonal colors pixel by pixel
for ($y=0;$y<$this->height['orig'];$y++)
{
for ($x=0;$x<$this->width['orig'];$x++)
{
$rgb = imagecolorat($this->original,$x,$y);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
//This is where we actually use yiq to modify our rbg values, and then convert them to our grayscale palette
$gs = $this->colorToGray($r,$g,$b);
imagesetpixel($this->edited,$x,$y,$palette[$gs]);
}
}
} | [
"public",
"function",
"toGrayscale",
"(",
")",
"{",
"$",
"this",
"->",
"getInfo",
"(",
")",
";",
"$",
"this",
"->",
"edited",
"=",
"imagecreate",
"(",
"$",
"this",
"->",
"width",
"[",
"'orig'",
"]",
",",
"$",
"this",
"->",
"height",
"[",
"'orig'",
"]",
")",
";",
"//Creates the 256 color palette",
"for",
"(",
"$",
"c",
"=",
"0",
";",
"$",
"c",
"<",
"256",
";",
"$",
"c",
"++",
")",
"{",
"$",
"palette",
"[",
"$",
"c",
"]",
"=",
"imagecolorallocate",
"(",
"$",
"this",
"->",
"edited",
",",
"$",
"c",
",",
"$",
"c",
",",
"$",
"c",
")",
";",
"}",
"//Reads the origonal colors pixel by pixel",
"for",
"(",
"$",
"y",
"=",
"0",
";",
"$",
"y",
"<",
"$",
"this",
"->",
"height",
"[",
"'orig'",
"]",
";",
"$",
"y",
"++",
")",
"{",
"for",
"(",
"$",
"x",
"=",
"0",
";",
"$",
"x",
"<",
"$",
"this",
"->",
"width",
"[",
"'orig'",
"]",
";",
"$",
"x",
"++",
")",
"{",
"$",
"rgb",
"=",
"imagecolorat",
"(",
"$",
"this",
"->",
"original",
",",
"$",
"x",
",",
"$",
"y",
")",
";",
"$",
"r",
"=",
"(",
"$",
"rgb",
">>",
"16",
")",
"&",
"0xFF",
";",
"$",
"g",
"=",
"(",
"$",
"rgb",
">>",
"8",
")",
"&",
"0xFF",
";",
"$",
"b",
"=",
"$",
"rgb",
"&",
"0xFF",
";",
"//This is where we actually use yiq to modify our rbg values, and then convert them to our grayscale palette",
"$",
"gs",
"=",
"$",
"this",
"->",
"colorToGray",
"(",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
")",
";",
"imagesetpixel",
"(",
"$",
"this",
"->",
"edited",
",",
"$",
"x",
",",
"$",
"y",
",",
"$",
"palette",
"[",
"$",
"gs",
"]",
")",
";",
"}",
"}",
"}"
] | Converts the image being edited to grayscale | [
"Converts",
"the",
"image",
"being",
"edited",
"to",
"grayscale"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Image.php#L225-L256 |
surebert/surebert-framework | src/sb/Image.php | Image.rotate | public function rotate($rotation)
{
if(isset($this->edited)){
$this->getInfo();
$this->edited = imagerotate($this->edited, $rotation, 0);
} else {
$this->edited = imagerotate($this->original, $rotation, 0);
}
} | php | public function rotate($rotation)
{
if(isset($this->edited)){
$this->getInfo();
$this->edited = imagerotate($this->edited, $rotation, 0);
} else {
$this->edited = imagerotate($this->original, $rotation, 0);
}
} | [
"public",
"function",
"rotate",
"(",
"$",
"rotation",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"edited",
")",
")",
"{",
"$",
"this",
"->",
"getInfo",
"(",
")",
";",
"$",
"this",
"->",
"edited",
"=",
"imagerotate",
"(",
"$",
"this",
"->",
"edited",
",",
"$",
"rotation",
",",
"0",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"edited",
"=",
"imagerotate",
"(",
"$",
"this",
"->",
"original",
",",
"$",
"rotation",
",",
"0",
")",
";",
"}",
"}"
] | Rotates an image the number of degrees specified by $rotation
@param int $rotation | [
"Rotates",
"an",
"image",
"the",
"number",
"of",
"degrees",
"specified",
"by",
"$rotation"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Image.php#L276-L285 |
surebert/surebert-framework | src/sb/Image.php | Image.write | public function write($text, $params=array())
{
$color = (isset($params['color'])) ? $params['color'] : array(0, 0, 0);
$color = imagecolorallocate($this->edited, $color[0], $color[1], $color[2]);
$size = (isset($params['size']))? $params['size'] : 5;
$x = (isset($params['x']))? $params['x'] : 2;
$y = (isset($params['y']))? $params['y'] : 2;
imagestring($this->edited, $size, $x, $y, $text, $color);
} | php | public function write($text, $params=array())
{
$color = (isset($params['color'])) ? $params['color'] : array(0, 0, 0);
$color = imagecolorallocate($this->edited, $color[0], $color[1], $color[2]);
$size = (isset($params['size']))? $params['size'] : 5;
$x = (isset($params['x']))? $params['x'] : 2;
$y = (isset($params['y']))? $params['y'] : 2;
imagestring($this->edited, $size, $x, $y, $text, $color);
} | [
"public",
"function",
"write",
"(",
"$",
"text",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"color",
"=",
"(",
"isset",
"(",
"$",
"params",
"[",
"'color'",
"]",
")",
")",
"?",
"$",
"params",
"[",
"'color'",
"]",
":",
"array",
"(",
"0",
",",
"0",
",",
"0",
")",
";",
"$",
"color",
"=",
"imagecolorallocate",
"(",
"$",
"this",
"->",
"edited",
",",
"$",
"color",
"[",
"0",
"]",
",",
"$",
"color",
"[",
"1",
"]",
",",
"$",
"color",
"[",
"2",
"]",
")",
";",
"$",
"size",
"=",
"(",
"isset",
"(",
"$",
"params",
"[",
"'size'",
"]",
")",
")",
"?",
"$",
"params",
"[",
"'size'",
"]",
":",
"5",
";",
"$",
"x",
"=",
"(",
"isset",
"(",
"$",
"params",
"[",
"'x'",
"]",
")",
")",
"?",
"$",
"params",
"[",
"'x'",
"]",
":",
"2",
";",
"$",
"y",
"=",
"(",
"isset",
"(",
"$",
"params",
"[",
"'y'",
"]",
")",
")",
"?",
"$",
"params",
"[",
"'y'",
"]",
":",
"2",
";",
"imagestring",
"(",
"$",
"this",
"->",
"edited",
",",
"$",
"size",
",",
"$",
"x",
",",
"$",
"y",
",",
"$",
"text",
",",
"$",
"color",
")",
";",
"}"
] | Write text onto an image
@param string $text
@param array $params color array(r,g,b), size, x, y | [
"Write",
"text",
"onto",
"an",
"image"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Image.php#L301-L311 |
surebert/surebert-framework | src/sb/Image.php | Image.toFile | public function toFile()
{
if ($this->type == "jpg")
{
$this->toJpg();
} elseif ($this->type == "png") {
$this->toPng();
} elseif ($this->type == "gif") {
$this->toGif();
}
} | php | public function toFile()
{
if ($this->type == "jpg")
{
$this->toJpg();
} elseif ($this->type == "png") {
$this->toPng();
} elseif ($this->type == "gif") {
$this->toGif();
}
} | [
"public",
"function",
"toFile",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"type",
"==",
"\"jpg\"",
")",
"{",
"$",
"this",
"->",
"toJpg",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"type",
"==",
"\"png\"",
")",
"{",
"$",
"this",
"->",
"toPng",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"type",
"==",
"\"gif\"",
")",
"{",
"$",
"this",
"->",
"toGif",
"(",
")",
";",
"}",
"}"
] | Saves the edited image as a file based on the original images file type | [
"Saves",
"the",
"edited",
"image",
"as",
"a",
"file",
"based",
"on",
"the",
"original",
"images",
"file",
"type"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Image.php#L358-L376 |
surebert/surebert-framework | src/sb/Image.php | Image.display | public function display()
{
if(isset($this->edited )){
$image = $this->edited;
} else {
$image = $this->original;
}
if ($this->type == "jpg")
{
header("Content-type: image/jpeg");
imagejpeg($image);
} elseif ($this->type == "png") {
header("Content-type: image/png");
imagepng($image);
} elseif ($this->type == "gif") {
header("Content-type: image/gif");
imagegif($image);
}
} | php | public function display()
{
if(isset($this->edited )){
$image = $this->edited;
} else {
$image = $this->original;
}
if ($this->type == "jpg")
{
header("Content-type: image/jpeg");
imagejpeg($image);
} elseif ($this->type == "png") {
header("Content-type: image/png");
imagepng($image);
} elseif ($this->type == "gif") {
header("Content-type: image/gif");
imagegif($image);
}
} | [
"public",
"function",
"display",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"edited",
")",
")",
"{",
"$",
"image",
"=",
"$",
"this",
"->",
"edited",
";",
"}",
"else",
"{",
"$",
"image",
"=",
"$",
"this",
"->",
"original",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"type",
"==",
"\"jpg\"",
")",
"{",
"header",
"(",
"\"Content-type: image/jpeg\"",
")",
";",
"imagejpeg",
"(",
"$",
"image",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"type",
"==",
"\"png\"",
")",
"{",
"header",
"(",
"\"Content-type: image/png\"",
")",
";",
"imagepng",
"(",
"$",
"image",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"type",
"==",
"\"gif\"",
")",
"{",
"header",
"(",
"\"Content-type: image/gif\"",
")",
";",
"imagegif",
"(",
"$",
"image",
")",
";",
"}",
"}"
] | Displays the edited image to screen as a dynamic image file | [
"Displays",
"the",
"edited",
"image",
"to",
"screen",
"as",
"a",
"dynamic",
"image",
"file"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Image.php#L382-L406 |
surebert/surebert-framework | src/sb/Image.php | Image.forceDownload | public function forceDownload()
{
if ($this->type == "jpg")
{
$this->toJpg();
} elseif ($this->type == "png") {
$this->toPng();
} elseif ($this->type == "gif") {
$this->toGif();
}
header('Content-Description: File Transfer');
header("Content-Type: application/octet-stream");
header('Content-Length: ' . filesize($this->path));
header('Content-Disposition: attachment; filename="' . basename($this->path.'"'));
readfile($this->path);
//remove the temp file
unlink($this->path);
} | php | public function forceDownload()
{
if ($this->type == "jpg")
{
$this->toJpg();
} elseif ($this->type == "png") {
$this->toPng();
} elseif ($this->type == "gif") {
$this->toGif();
}
header('Content-Description: File Transfer');
header("Content-Type: application/octet-stream");
header('Content-Length: ' . filesize($this->path));
header('Content-Disposition: attachment; filename="' . basename($this->path.'"'));
readfile($this->path);
//remove the temp file
unlink($this->path);
} | [
"public",
"function",
"forceDownload",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"type",
"==",
"\"jpg\"",
")",
"{",
"$",
"this",
"->",
"toJpg",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"type",
"==",
"\"png\"",
")",
"{",
"$",
"this",
"->",
"toPng",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"type",
"==",
"\"gif\"",
")",
"{",
"$",
"this",
"->",
"toGif",
"(",
")",
";",
"}",
"header",
"(",
"'Content-Description: File Transfer'",
")",
";",
"header",
"(",
"\"Content-Type: application/octet-stream\"",
")",
";",
"header",
"(",
"'Content-Length: '",
".",
"filesize",
"(",
"$",
"this",
"->",
"path",
")",
")",
";",
"header",
"(",
"'Content-Disposition: attachment; filename=\"'",
".",
"basename",
"(",
"$",
"this",
"->",
"path",
".",
"'\"'",
")",
")",
";",
"readfile",
"(",
"$",
"this",
"->",
"path",
")",
";",
"//remove the temp file",
"unlink",
"(",
"$",
"this",
"->",
"path",
")",
";",
"}"
] | Forces the image being manipulated to the user as a force download | [
"Forces",
"the",
"image",
"being",
"manipulated",
"to",
"the",
"user",
"as",
"a",
"force",
"download"
] | train | https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Image.php#L412-L439 |
oroinc/OroLayoutComponent | Block.php | Block.getTypeName | public function getTypeName()
{
$blockType = $this->rawLayout->getProperty($this->id, RawLayout::BLOCK_TYPE, true);
return $blockType instanceof BlockTypeInterface
? $blockType->getName()
: $blockType;
} | php | public function getTypeName()
{
$blockType = $this->rawLayout->getProperty($this->id, RawLayout::BLOCK_TYPE, true);
return $blockType instanceof BlockTypeInterface
? $blockType->getName()
: $blockType;
} | [
"public",
"function",
"getTypeName",
"(",
")",
"{",
"$",
"blockType",
"=",
"$",
"this",
"->",
"rawLayout",
"->",
"getProperty",
"(",
"$",
"this",
"->",
"id",
",",
"RawLayout",
"::",
"BLOCK_TYPE",
",",
"true",
")",
";",
"return",
"$",
"blockType",
"instanceof",
"BlockTypeInterface",
"?",
"$",
"blockType",
"->",
"getName",
"(",
")",
":",
"$",
"blockType",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Block.php#L65-L72 |
oroinc/OroLayoutComponent | Block.php | Block.getParent | public function getParent()
{
if ($this->parent === false) {
$parentId = $this->rawLayout->getParentId($this->id);
if ($parentId) {
$this->parent = new self($this->rawLayout, $this->typeHelper, $this->context, $this->data);
$this->parent->initialize($parentId);
} else {
$this->parent = null;
}
}
return $this->parent;
} | php | public function getParent()
{
if ($this->parent === false) {
$parentId = $this->rawLayout->getParentId($this->id);
if ($parentId) {
$this->parent = new self($this->rawLayout, $this->typeHelper, $this->context, $this->data);
$this->parent->initialize($parentId);
} else {
$this->parent = null;
}
}
return $this->parent;
} | [
"public",
"function",
"getParent",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"parent",
"===",
"false",
")",
"{",
"$",
"parentId",
"=",
"$",
"this",
"->",
"rawLayout",
"->",
"getParentId",
"(",
"$",
"this",
"->",
"id",
")",
";",
"if",
"(",
"$",
"parentId",
")",
"{",
"$",
"this",
"->",
"parent",
"=",
"new",
"self",
"(",
"$",
"this",
"->",
"rawLayout",
",",
"$",
"this",
"->",
"typeHelper",
",",
"$",
"this",
"->",
"context",
",",
"$",
"this",
"->",
"data",
")",
";",
"$",
"this",
"->",
"parent",
"->",
"initialize",
"(",
"$",
"parentId",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"parent",
"=",
"null",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"parent",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Block.php#L85-L98 |
Eluinhost/php-yggdrasil | src/DefaultYggdrasil.php | DefaultYggdrasil.parseTexturesProperties | private function parseTexturesProperties($propertiesArray)
{
foreach($propertiesArray as $property) {
if($property['name'] == 'textures') {
$texturesJSON = json_decode(base64_decode($property['value']), true);
$properties = new PlayerProperties(
$texturesJSON['timestamp'],
$texturesJSON['profileId'],
$texturesJSON['profileName']
);
if(isset($texturesJSON['isPublic'])) {
$properties->setPublic($texturesJSON['isPublic']);
}
if(array_key_exists('SKIN', $texturesJSON['textures'])) {
$properties->setSkinTexture($texturesJSON['textures']['SKIN']['url']);
}
if(array_key_exists('CAPE', $texturesJSON['textures'])) {
$properties->setCapeTexture($texturesJSON['textures']['CAPE']['url']);
}
return $properties;
}
}
return null;
} | php | private function parseTexturesProperties($propertiesArray)
{
foreach($propertiesArray as $property) {
if($property['name'] == 'textures') {
$texturesJSON = json_decode(base64_decode($property['value']), true);
$properties = new PlayerProperties(
$texturesJSON['timestamp'],
$texturesJSON['profileId'],
$texturesJSON['profileName']
);
if(isset($texturesJSON['isPublic'])) {
$properties->setPublic($texturesJSON['isPublic']);
}
if(array_key_exists('SKIN', $texturesJSON['textures'])) {
$properties->setSkinTexture($texturesJSON['textures']['SKIN']['url']);
}
if(array_key_exists('CAPE', $texturesJSON['textures'])) {
$properties->setCapeTexture($texturesJSON['textures']['CAPE']['url']);
}
return $properties;
}
}
return null;
} | [
"private",
"function",
"parseTexturesProperties",
"(",
"$",
"propertiesArray",
")",
"{",
"foreach",
"(",
"$",
"propertiesArray",
"as",
"$",
"property",
")",
"{",
"if",
"(",
"$",
"property",
"[",
"'name'",
"]",
"==",
"'textures'",
")",
"{",
"$",
"texturesJSON",
"=",
"json_decode",
"(",
"base64_decode",
"(",
"$",
"property",
"[",
"'value'",
"]",
")",
",",
"true",
")",
";",
"$",
"properties",
"=",
"new",
"PlayerProperties",
"(",
"$",
"texturesJSON",
"[",
"'timestamp'",
"]",
",",
"$",
"texturesJSON",
"[",
"'profileId'",
"]",
",",
"$",
"texturesJSON",
"[",
"'profileName'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"texturesJSON",
"[",
"'isPublic'",
"]",
")",
")",
"{",
"$",
"properties",
"->",
"setPublic",
"(",
"$",
"texturesJSON",
"[",
"'isPublic'",
"]",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'SKIN'",
",",
"$",
"texturesJSON",
"[",
"'textures'",
"]",
")",
")",
"{",
"$",
"properties",
"->",
"setSkinTexture",
"(",
"$",
"texturesJSON",
"[",
"'textures'",
"]",
"[",
"'SKIN'",
"]",
"[",
"'url'",
"]",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'CAPE'",
",",
"$",
"texturesJSON",
"[",
"'textures'",
"]",
")",
")",
"{",
"$",
"properties",
"->",
"setCapeTexture",
"(",
"$",
"texturesJSON",
"[",
"'textures'",
"]",
"[",
"'CAPE'",
"]",
"[",
"'url'",
"]",
")",
";",
"}",
"return",
"$",
"properties",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Checks the array for a properties with name 'textures' and creates a PlayerProperties for it
@param $propertiesArray array the array of properties
@return PlayerProperties the parsed properties or null if textures property not found | [
"Checks",
"the",
"array",
"for",
"a",
"properties",
"with",
"name",
"textures",
"and",
"creates",
"a",
"PlayerProperties",
"for",
"it"
] | train | https://github.com/Eluinhost/php-yggdrasil/blob/9513f67e7c88f1e92eaacb564a727f23b84c5525/src/DefaultYggdrasil.php#L41-L68 |
Eluinhost/php-yggdrasil | src/DefaultYggdrasil.php | DefaultYggdrasil.getAuthServerResponse | private function getAuthServerResponse($subURL, $jsonData)
{
return $this->getResponse(
self::AUTH_SERVER_URL . $subURL,
[
'json' => $jsonData,
'headers' => [
'Content-Type' => 'application/json'
]
],
true
);
} | php | private function getAuthServerResponse($subURL, $jsonData)
{
return $this->getResponse(
self::AUTH_SERVER_URL . $subURL,
[
'json' => $jsonData,
'headers' => [
'Content-Type' => 'application/json'
]
],
true
);
} | [
"private",
"function",
"getAuthServerResponse",
"(",
"$",
"subURL",
",",
"$",
"jsonData",
")",
"{",
"return",
"$",
"this",
"->",
"getResponse",
"(",
"self",
"::",
"AUTH_SERVER_URL",
".",
"$",
"subURL",
",",
"[",
"'json'",
"=>",
"$",
"jsonData",
",",
"'headers'",
"=>",
"[",
"'Content-Type'",
"=>",
"'application/json'",
"]",
"]",
",",
"true",
")",
";",
"}"
] | Shortcut to getResponse using self::AUTH_SERVER_URL as a base
@param $subURL String the url to append to AUTH_SERVER_URL
@param $jsonData array the json payload
@throws APIRequestException if a non 200 code with the error details from the server
@return array json response | [
"Shortcut",
"to",
"getResponse",
"using",
"self",
"::",
"AUTH_SERVER_URL",
"as",
"a",
"base"
] | train | https://github.com/Eluinhost/php-yggdrasil/blob/9513f67e7c88f1e92eaacb564a727f23b84c5525/src/DefaultYggdrasil.php#L78-L90 |
Eluinhost/php-yggdrasil | src/DefaultYggdrasil.php | DefaultYggdrasil.getSessionServerResponse | private function getSessionServerResponse($subURL, $queryParameters = [])
{
return $this->getResponse(
self::SESSION_SERVER . $subURL,
[
'query' => $queryParameters
],
false
);
} | php | private function getSessionServerResponse($subURL, $queryParameters = [])
{
return $this->getResponse(
self::SESSION_SERVER . $subURL,
[
'query' => $queryParameters
],
false
);
} | [
"private",
"function",
"getSessionServerResponse",
"(",
"$",
"subURL",
",",
"$",
"queryParameters",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"getResponse",
"(",
"self",
"::",
"SESSION_SERVER",
".",
"$",
"subURL",
",",
"[",
"'query'",
"=>",
"$",
"queryParameters",
"]",
",",
"false",
")",
";",
"}"
] | Shortcut to getResponse using self::SESSION_SERVER_URL as a base
@param $subURL String the url to append to SESSION_SERVER_URL
@param $queryParameters array an assoc array of the get parameters to set
@throws APIRequestException if a non 200 code with the error details from the server
@return array json response | [
"Shortcut",
"to",
"getResponse",
"using",
"self",
"::",
"SESSION_SERVER_URL",
"as",
"a",
"base"
] | train | https://github.com/Eluinhost/php-yggdrasil/blob/9513f67e7c88f1e92eaacb564a727f23b84c5525/src/DefaultYggdrasil.php#L100-L109 |
Eluinhost/php-yggdrasil | src/DefaultYggdrasil.php | DefaultYggdrasil.getResponse | private function getResponse($url, $options, $post)
{
if($post) {
$response = $this->httpClient->post($url, $options);
} else {
$response = $this->httpClient->get($url, $options);
}
if( $response->getStatusCode() != 200 ) {
$json = $response->json();
$short = $json['error'];
$error = $json['errorMessage'];
$cause = $json['cause'];
throw new APIRequestException(
$short == null ? 'Unknown Error' : $short,
$error == null ? 'Unknown Error' : $error,
$cause == null ? '' : $cause
);
}
return $response->json();
} | php | private function getResponse($url, $options, $post)
{
if($post) {
$response = $this->httpClient->post($url, $options);
} else {
$response = $this->httpClient->get($url, $options);
}
if( $response->getStatusCode() != 200 ) {
$json = $response->json();
$short = $json['error'];
$error = $json['errorMessage'];
$cause = $json['cause'];
throw new APIRequestException(
$short == null ? 'Unknown Error' : $short,
$error == null ? 'Unknown Error' : $error,
$cause == null ? '' : $cause
);
}
return $response->json();
} | [
"private",
"function",
"getResponse",
"(",
"$",
"url",
",",
"$",
"options",
",",
"$",
"post",
")",
"{",
"if",
"(",
"$",
"post",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"httpClient",
"->",
"post",
"(",
"$",
"url",
",",
"$",
"options",
")",
";",
"}",
"else",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"httpClient",
"->",
"get",
"(",
"$",
"url",
",",
"$",
"options",
")",
";",
"}",
"if",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
"!=",
"200",
")",
"{",
"$",
"json",
"=",
"$",
"response",
"->",
"json",
"(",
")",
";",
"$",
"short",
"=",
"$",
"json",
"[",
"'error'",
"]",
";",
"$",
"error",
"=",
"$",
"json",
"[",
"'errorMessage'",
"]",
";",
"$",
"cause",
"=",
"$",
"json",
"[",
"'cause'",
"]",
";",
"throw",
"new",
"APIRequestException",
"(",
"$",
"short",
"==",
"null",
"?",
"'Unknown Error'",
":",
"$",
"short",
",",
"$",
"error",
"==",
"null",
"?",
"'Unknown Error'",
":",
"$",
"error",
",",
"$",
"cause",
"==",
"null",
"?",
"''",
":",
"$",
"cause",
")",
";",
"}",
"return",
"$",
"response",
"->",
"json",
"(",
")",
";",
"}"
] | Get a response from the given subURL via POST with the given JSON data. Sets header Content-Type for JSON
@param $url String the full URL to request
@param $options array the options to set on the request
@param $post boolean if true uses POST, otherwise uses GET
@throws APIRequestException if a non 200 code with the error details from the server
@return array json response | [
"Get",
"a",
"response",
"from",
"the",
"given",
"subURL",
"via",
"POST",
"with",
"the",
"given",
"JSON",
"data",
".",
"Sets",
"header",
"Content",
"-",
"Type",
"for",
"JSON"
] | train | https://github.com/Eluinhost/php-yggdrasil/blob/9513f67e7c88f1e92eaacb564a727f23b84c5525/src/DefaultYggdrasil.php#L120-L139 |
technote-space/wordpress-plugin-base | src/technote_mock.php | Technote.translate | private function translate( $value ) {
$textdomain = $this->get_textdomain();
if ( ! empty( $textdomain ) ) {
$translated = __( $value, $textdomain );
if ( $value !== $translated ) {
return $translated;
}
}
return __( $value, TECHNOTE_PLUGIN );
} | php | private function translate( $value ) {
$textdomain = $this->get_textdomain();
if ( ! empty( $textdomain ) ) {
$translated = __( $value, $textdomain );
if ( $value !== $translated ) {
return $translated;
}
}
return __( $value, TECHNOTE_PLUGIN );
} | [
"private",
"function",
"translate",
"(",
"$",
"value",
")",
"{",
"$",
"textdomain",
"=",
"$",
"this",
"->",
"get_textdomain",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"textdomain",
")",
")",
"{",
"$",
"translated",
"=",
"__",
"(",
"$",
"value",
",",
"$",
"textdomain",
")",
";",
"if",
"(",
"$",
"value",
"!==",
"$",
"translated",
")",
"{",
"return",
"$",
"translated",
";",
"}",
"}",
"return",
"__",
"(",
"$",
"value",
",",
"TECHNOTE_PLUGIN",
")",
";",
"}"
] | @since 1.2.1
@param $value
@return string | [
"@since",
"1",
".",
"2",
".",
"1"
] | train | https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/technote_mock.php#L137-L147 |
technote-space/wordpress-plugin-base | src/technote_mock.php | Technote.get_instance | public static function get_instance( $plugin_name, $plugin_file ) {
if ( ! isset( self::$_instances[ $plugin_name ] ) ) {
self::$_instances[ $plugin_name ] = new static( $plugin_name, $plugin_file );
}
return self::$_instances[ $plugin_name ];
} | php | public static function get_instance( $plugin_name, $plugin_file ) {
if ( ! isset( self::$_instances[ $plugin_name ] ) ) {
self::$_instances[ $plugin_name ] = new static( $plugin_name, $plugin_file );
}
return self::$_instances[ $plugin_name ];
} | [
"public",
"static",
"function",
"get_instance",
"(",
"$",
"plugin_name",
",",
"$",
"plugin_file",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"_instances",
"[",
"$",
"plugin_name",
"]",
")",
")",
"{",
"self",
"::",
"$",
"_instances",
"[",
"$",
"plugin_name",
"]",
"=",
"new",
"static",
"(",
"$",
"plugin_name",
",",
"$",
"plugin_file",
")",
";",
"}",
"return",
"self",
"::",
"$",
"_instances",
"[",
"$",
"plugin_name",
"]",
";",
"}"
] | @param string $plugin_name
@param string $plugin_file
@return Technote | [
"@param",
"string",
"$plugin_name",
"@param",
"string",
"$plugin_file"
] | train | https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/technote_mock.php#L155-L161 |
technote-space/wordpress-plugin-base | src/technote_mock.php | Technote.init | public function init() {
if ( ! function_exists( 'get_plugin_data' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$this->plugin_data = get_plugin_data( $this->plugin_file, false, false );
} | php | public function init() {
if ( ! function_exists( 'get_plugin_data' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$this->plugin_data = get_plugin_data( $this->plugin_file, false, false );
} | [
"public",
"function",
"init",
"(",
")",
"{",
"if",
"(",
"!",
"function_exists",
"(",
"'get_plugin_data'",
")",
")",
"{",
"require_once",
"ABSPATH",
".",
"'wp-admin/includes/plugin.php'",
";",
"}",
"$",
"this",
"->",
"plugin_data",
"=",
"get_plugin_data",
"(",
"$",
"this",
"->",
"plugin_file",
",",
"false",
",",
"false",
")",
";",
"}"
] | init
@since 2.1.0 | [
"init"
] | train | https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/technote_mock.php#L175-L180 |
highday/glitter | src/Audit/Listeners/Member/LogCreate.php | LogCreate.handle | public function handle(MemberCreated $event)
{
if (is_null($event->actor)) {
return;
}
$data = [
'ip' => request()->ip(),
'ua' => request()->header('User-Agent'),
];
$event->actor->log('member.create', $data);
} | php | public function handle(MemberCreated $event)
{
if (is_null($event->actor)) {
return;
}
$data = [
'ip' => request()->ip(),
'ua' => request()->header('User-Agent'),
];
$event->actor->log('member.create', $data);
} | [
"public",
"function",
"handle",
"(",
"MemberCreated",
"$",
"event",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"event",
"->",
"actor",
")",
")",
"{",
"return",
";",
"}",
"$",
"data",
"=",
"[",
"'ip'",
"=>",
"request",
"(",
")",
"->",
"ip",
"(",
")",
",",
"'ua'",
"=>",
"request",
"(",
")",
"->",
"header",
"(",
"'User-Agent'",
")",
",",
"]",
";",
"$",
"event",
"->",
"actor",
"->",
"log",
"(",
"'member.create'",
",",
"$",
"data",
")",
";",
"}"
] | Handle the event.
@param MemberCreated $event
@return void | [
"Handle",
"the",
"event",
"."
] | train | https://github.com/highday/glitter/blob/d1c7a227fd2343806bd3ec0314e621ced57dfe66/src/Audit/Listeners/Member/LogCreate.php#L26-L38 |
zhouyl/mellivora | Mellivora/Database/DatabaseServiceProvider.php | DatabaseServiceProvider.register | public function register()
{
$this->registerConnectionServices();
$this->registerEloquentFactory();
$this->registerQueueableEntityResolver();
Model::setConnectionResolver($this->container['db']);
Model::setEventDispatcher($this->container['events']);
Model::clearBootedModels();
Model::observe(InternalObserve::class);
} | php | public function register()
{
$this->registerConnectionServices();
$this->registerEloquentFactory();
$this->registerQueueableEntityResolver();
Model::setConnectionResolver($this->container['db']);
Model::setEventDispatcher($this->container['events']);
Model::clearBootedModels();
Model::observe(InternalObserve::class);
} | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"registerConnectionServices",
"(",
")",
";",
"$",
"this",
"->",
"registerEloquentFactory",
"(",
")",
";",
"$",
"this",
"->",
"registerQueueableEntityResolver",
"(",
")",
";",
"Model",
"::",
"setConnectionResolver",
"(",
"$",
"this",
"->",
"container",
"[",
"'db'",
"]",
")",
";",
"Model",
"::",
"setEventDispatcher",
"(",
"$",
"this",
"->",
"container",
"[",
"'events'",
"]",
")",
";",
"Model",
"::",
"clearBootedModels",
"(",
")",
";",
"Model",
"::",
"observe",
"(",
"InternalObserve",
"::",
"class",
")",
";",
"}"
] | Register the service provider.
@return void | [
"Register",
"the",
"service",
"provider",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/DatabaseServiceProvider.php#L20-L30 |
zhouyl/mellivora | Mellivora/Database/DatabaseServiceProvider.php | DatabaseServiceProvider.registerConnectionServices | protected function registerConnectionServices()
{
// The connection factory is used to create the actual connection instances on
// the database. We will inject the factory into the manager so that it may
// make the connections while they are actually needed and not of before.
$this->container['db.factory'] = function ($container) {
return new ConnectionFactory($container);
};
// The database manager is used to resolve various connections, since multiple
// connections might be managed. It also implements the connection resolver
// interface which may be used by other components requiring connections.
$this->container['db'] = function ($container) {
return new DatabaseManager($container, $container['db.factory']);
};
$this->container['db.connection'] = function ($container) {
return $container['db']->connection();
};
} | php | protected function registerConnectionServices()
{
// The connection factory is used to create the actual connection instances on
// the database. We will inject the factory into the manager so that it may
// make the connections while they are actually needed and not of before.
$this->container['db.factory'] = function ($container) {
return new ConnectionFactory($container);
};
// The database manager is used to resolve various connections, since multiple
// connections might be managed. It also implements the connection resolver
// interface which may be used by other components requiring connections.
$this->container['db'] = function ($container) {
return new DatabaseManager($container, $container['db.factory']);
};
$this->container['db.connection'] = function ($container) {
return $container['db']->connection();
};
} | [
"protected",
"function",
"registerConnectionServices",
"(",
")",
"{",
"// The connection factory is used to create the actual connection instances on",
"// the database. We will inject the factory into the manager so that it may",
"// make the connections while they are actually needed and not of before.",
"$",
"this",
"->",
"container",
"[",
"'db.factory'",
"]",
"=",
"function",
"(",
"$",
"container",
")",
"{",
"return",
"new",
"ConnectionFactory",
"(",
"$",
"container",
")",
";",
"}",
";",
"// The database manager is used to resolve various connections, since multiple",
"// connections might be managed. It also implements the connection resolver",
"// interface which may be used by other components requiring connections.",
"$",
"this",
"->",
"container",
"[",
"'db'",
"]",
"=",
"function",
"(",
"$",
"container",
")",
"{",
"return",
"new",
"DatabaseManager",
"(",
"$",
"container",
",",
"$",
"container",
"[",
"'db.factory'",
"]",
")",
";",
"}",
";",
"$",
"this",
"->",
"container",
"[",
"'db.connection'",
"]",
"=",
"function",
"(",
"$",
"container",
")",
"{",
"return",
"$",
"container",
"[",
"'db'",
"]",
"->",
"connection",
"(",
")",
";",
"}",
";",
"}"
] | Register the primary database bindings.
@return void | [
"Register",
"the",
"primary",
"database",
"bindings",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/DatabaseServiceProvider.php#L37-L56 |
zhouyl/mellivora | Mellivora/Database/DatabaseServiceProvider.php | DatabaseServiceProvider.registerEloquentFactory | protected function registerEloquentFactory()
{
$this->container['db.faker'] = function () {
return FakerFactory::create();
};
$this->container['db.eloquent'] = function ($container) {
return EloquentFactory::construct(
$container['db.faker'],
database_path('factories')
);
};
} | php | protected function registerEloquentFactory()
{
$this->container['db.faker'] = function () {
return FakerFactory::create();
};
$this->container['db.eloquent'] = function ($container) {
return EloquentFactory::construct(
$container['db.faker'],
database_path('factories')
);
};
} | [
"protected",
"function",
"registerEloquentFactory",
"(",
")",
"{",
"$",
"this",
"->",
"container",
"[",
"'db.faker'",
"]",
"=",
"function",
"(",
")",
"{",
"return",
"FakerFactory",
"::",
"create",
"(",
")",
";",
"}",
";",
"$",
"this",
"->",
"container",
"[",
"'db.eloquent'",
"]",
"=",
"function",
"(",
"$",
"container",
")",
"{",
"return",
"EloquentFactory",
"::",
"construct",
"(",
"$",
"container",
"[",
"'db.faker'",
"]",
",",
"database_path",
"(",
"'factories'",
")",
")",
";",
"}",
";",
"}"
] | Register the Eloquent factory instance in the container.
@return void | [
"Register",
"the",
"Eloquent",
"factory",
"instance",
"in",
"the",
"container",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/DatabaseServiceProvider.php#L63-L75 |
alchemy-fr/GeonamesServer-PHP-Plugin | src/Alchemy/Geonames/Geoname.php | Geoname.get | public function get($property)
{
return isset($this->data[$property]) ? $this->data[$property] : null;
} | php | public function get($property)
{
return isset($this->data[$property]) ? $this->data[$property] : null;
} | [
"public",
"function",
"get",
"(",
"$",
"property",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"property",
"]",
")",
"?",
"$",
"this",
"->",
"data",
"[",
"$",
"property",
"]",
":",
"null",
";",
"}"
] | Returns the value of a given property.
@param string $property
@return mixed|null | [
"Returns",
"the",
"value",
"of",
"a",
"given",
"property",
"."
] | train | https://github.com/alchemy-fr/GeonamesServer-PHP-Plugin/blob/a14bd64b2badaf65ff03cca37ca52bff65f31152/src/Alchemy/Geonames/Geoname.php#L35-L38 |
codeages/beanstalk-client | src/Client.php | Client.connect | public function connect()
{
if (isset($this->_connection)) {
$this->disconnect();
}
$function = $this->_config['persistent'] ? 'pfsockopen' : 'fsockopen';
$params = [$this->_config['host'], $this->_config['port'], &$errNum, &$errStr];
if ($this->_config['timeout']) {
$params[] = $this->_config['timeout'];
}
$this->_connection = @call_user_func_array($function, $params);
if (!empty($errNum) || !empty($errStr)) {
throw new ConnectionException("{$errNum}: {$errStr} (connecting to {$this->_config['host']}:{$this->_config['port']})");
}
$this->connected = is_resource($this->_connection);
if (!$this->connected) {
throw new ConnectionException('Connected failed.');
}
stream_set_timeout($this->_connection, $this->_config['socket_timeout']);
return $this->connected;
} | php | public function connect()
{
if (isset($this->_connection)) {
$this->disconnect();
}
$function = $this->_config['persistent'] ? 'pfsockopen' : 'fsockopen';
$params = [$this->_config['host'], $this->_config['port'], &$errNum, &$errStr];
if ($this->_config['timeout']) {
$params[] = $this->_config['timeout'];
}
$this->_connection = @call_user_func_array($function, $params);
if (!empty($errNum) || !empty($errStr)) {
throw new ConnectionException("{$errNum}: {$errStr} (connecting to {$this->_config['host']}:{$this->_config['port']})");
}
$this->connected = is_resource($this->_connection);
if (!$this->connected) {
throw new ConnectionException('Connected failed.');
}
stream_set_timeout($this->_connection, $this->_config['socket_timeout']);
return $this->connected;
} | [
"public",
"function",
"connect",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_connection",
")",
")",
"{",
"$",
"this",
"->",
"disconnect",
"(",
")",
";",
"}",
"$",
"function",
"=",
"$",
"this",
"->",
"_config",
"[",
"'persistent'",
"]",
"?",
"'pfsockopen'",
":",
"'fsockopen'",
";",
"$",
"params",
"=",
"[",
"$",
"this",
"->",
"_config",
"[",
"'host'",
"]",
",",
"$",
"this",
"->",
"_config",
"[",
"'port'",
"]",
",",
"&",
"$",
"errNum",
",",
"&",
"$",
"errStr",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"_config",
"[",
"'timeout'",
"]",
")",
"{",
"$",
"params",
"[",
"]",
"=",
"$",
"this",
"->",
"_config",
"[",
"'timeout'",
"]",
";",
"}",
"$",
"this",
"->",
"_connection",
"=",
"@",
"call_user_func_array",
"(",
"$",
"function",
",",
"$",
"params",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"errNum",
")",
"||",
"!",
"empty",
"(",
"$",
"errStr",
")",
")",
"{",
"throw",
"new",
"ConnectionException",
"(",
"\"{$errNum}: {$errStr} (connecting to {$this->_config['host']}:{$this->_config['port']})\"",
")",
";",
"}",
"$",
"this",
"->",
"connected",
"=",
"is_resource",
"(",
"$",
"this",
"->",
"_connection",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"connected",
")",
"{",
"throw",
"new",
"ConnectionException",
"(",
"'Connected failed.'",
")",
";",
"}",
"stream_set_timeout",
"(",
"$",
"this",
"->",
"_connection",
",",
"$",
"this",
"->",
"_config",
"[",
"'socket_timeout'",
"]",
")",
";",
"return",
"$",
"this",
"->",
"connected",
";",
"}"
] | Initiates a socket connection to the beanstalk server. The resulting
stream will not have any timeout set on it. Which means it can wait
an unlimited amount of time until a packet becomes available. This
is required for doing blocking reads.
@see \Beanstalk\Client::$_connection
@see \Beanstalk\Client::reserve()
@return bool `true` if the connection was established, `false` otherwise. | [
"Initiates",
"a",
"socket",
"connection",
"to",
"the",
"beanstalk",
"server",
".",
"The",
"resulting",
"stream",
"will",
"not",
"have",
"any",
"timeout",
"set",
"on",
"it",
".",
"Which",
"means",
"it",
"can",
"wait",
"an",
"unlimited",
"amount",
"of",
"time",
"until",
"a",
"packet",
"becomes",
"available",
".",
"This",
"is",
"required",
"for",
"doing",
"blocking",
"reads",
"."
] | train | https://github.com/codeages/beanstalk-client/blob/097acad3cd9489413863f6cad86791216bc972e1/src/Client.php#L120-L146 |
codeages/beanstalk-client | src/Client.php | Client._write | protected function _write($data)
{
if (!$this->connected) {
$message = 'No connecting found while writing data to socket.';
throw new RuntimeException($message);
}
$data .= "\r\n";
$length = strlen($data);
$fwrited = fwrite($this->_connection, $data, $length);
if ($fwrited === false) {
throw new SocketException('Socket is broken, write failed: '.substr($data, 0, 100));
} elseif ($fwrited < $length) {
throw new SocketException("Socket is broken, only write {$fwrited} bytes of {$length} bytes: ".substr($data, 0, 100));
}
return $fwrited;
} | php | protected function _write($data)
{
if (!$this->connected) {
$message = 'No connecting found while writing data to socket.';
throw new RuntimeException($message);
}
$data .= "\r\n";
$length = strlen($data);
$fwrited = fwrite($this->_connection, $data, $length);
if ($fwrited === false) {
throw new SocketException('Socket is broken, write failed: '.substr($data, 0, 100));
} elseif ($fwrited < $length) {
throw new SocketException("Socket is broken, only write {$fwrited} bytes of {$length} bytes: ".substr($data, 0, 100));
}
return $fwrited;
} | [
"protected",
"function",
"_write",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"connected",
")",
"{",
"$",
"message",
"=",
"'No connecting found while writing data to socket.'",
";",
"throw",
"new",
"RuntimeException",
"(",
"$",
"message",
")",
";",
"}",
"$",
"data",
".=",
"\"\\r\\n\"",
";",
"$",
"length",
"=",
"strlen",
"(",
"$",
"data",
")",
";",
"$",
"fwrited",
"=",
"fwrite",
"(",
"$",
"this",
"->",
"_connection",
",",
"$",
"data",
",",
"$",
"length",
")",
";",
"if",
"(",
"$",
"fwrited",
"===",
"false",
")",
"{",
"throw",
"new",
"SocketException",
"(",
"'Socket is broken, write failed: '",
".",
"substr",
"(",
"$",
"data",
",",
"0",
",",
"100",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"fwrited",
"<",
"$",
"length",
")",
"{",
"throw",
"new",
"SocketException",
"(",
"\"Socket is broken, only write {$fwrited} bytes of {$length} bytes: \"",
".",
"substr",
"(",
"$",
"data",
",",
"0",
",",
"100",
")",
")",
";",
"}",
"return",
"$",
"fwrited",
";",
"}"
] | Writes a packet to the socket. Prior to writing to the socket will
check for availability of the connection.
@param string $data
@return int|bool number of written bytes or `false` on error. | [
"Writes",
"a",
"packet",
"to",
"the",
"socket",
".",
"Prior",
"to",
"writing",
"to",
"the",
"socket",
"will",
"check",
"for",
"availability",
"of",
"the",
"connection",
"."
] | train | https://github.com/codeages/beanstalk-client/blob/097acad3cd9489413863f6cad86791216bc972e1/src/Client.php#L178-L197 |
codeages/beanstalk-client | src/Client.php | Client.useTube | public function useTube($tube)
{
$this->_usingTube = $tube;
$this->_write(sprintf('use %s', $tube));
$status = strtok($this->_read(), ' ');
switch ($status) {
case 'USING':
return strtok(' ');
default:
throw new ServerException('UseTube error: '.$status);
}
} | php | public function useTube($tube)
{
$this->_usingTube = $tube;
$this->_write(sprintf('use %s', $tube));
$status = strtok($this->_read(), ' ');
switch ($status) {
case 'USING':
return strtok(' ');
default:
throw new ServerException('UseTube error: '.$status);
}
} | [
"public",
"function",
"useTube",
"(",
"$",
"tube",
")",
"{",
"$",
"this",
"->",
"_usingTube",
"=",
"$",
"tube",
";",
"$",
"this",
"->",
"_write",
"(",
"sprintf",
"(",
"'use %s'",
",",
"$",
"tube",
")",
")",
";",
"$",
"status",
"=",
"strtok",
"(",
"$",
"this",
"->",
"_read",
"(",
")",
",",
"' '",
")",
";",
"switch",
"(",
"$",
"status",
")",
"{",
"case",
"'USING'",
":",
"return",
"strtok",
"(",
"' '",
")",
";",
"default",
":",
"throw",
"new",
"ServerException",
"(",
"'UseTube error: '",
".",
"$",
"status",
")",
";",
"}",
"}"
] | The `use` command is for producers. Subsequent put commands will put
jobs into the tube specified by this command. If no use command has
been issued, jobs will be put into the tube named `default`.
@param string $tube A name at most 200 bytes. It specifies the tube to
use. If the tube does not exist, it will be created.
@return string|bool `false` on error otherwise the name of the tube. | [
"The",
"use",
"command",
"is",
"for",
"producers",
".",
"Subsequent",
"put",
"commands",
"will",
"put",
"jobs",
"into",
"the",
"tube",
"specified",
"by",
"this",
"command",
".",
"If",
"no",
"use",
"command",
"has",
"been",
"issued",
"jobs",
"will",
"be",
"put",
"into",
"the",
"tube",
"named",
"default",
"."
] | train | https://github.com/codeages/beanstalk-client/blob/097acad3cd9489413863f6cad86791216bc972e1/src/Client.php#L297-L309 |
codeages/beanstalk-client | src/Client.php | Client.reserve | public function reserve($timeout = null)
{
if (isset($timeout)) {
$this->_write(sprintf('reserve-with-timeout %d', $timeout));
} else {
$this->_write('reserve');
}
$status = strtok($this->_read(), ' ');
switch ($status) {
case 'RESERVED':
return [
'id' => (integer) strtok(' '),
'body' => $this->_read((integer) strtok(' ')),
];
case 'TIMED_OUT':
return false;
case 'DEADLINE_SOON':
throw new DeadlineSoonException('Reserve failed: '.$status);
default:
throw new ServerException('Reserve failed: '.$status);
}
} | php | public function reserve($timeout = null)
{
if (isset($timeout)) {
$this->_write(sprintf('reserve-with-timeout %d', $timeout));
} else {
$this->_write('reserve');
}
$status = strtok($this->_read(), ' ');
switch ($status) {
case 'RESERVED':
return [
'id' => (integer) strtok(' '),
'body' => $this->_read((integer) strtok(' ')),
];
case 'TIMED_OUT':
return false;
case 'DEADLINE_SOON':
throw new DeadlineSoonException('Reserve failed: '.$status);
default:
throw new ServerException('Reserve failed: '.$status);
}
} | [
"public",
"function",
"reserve",
"(",
"$",
"timeout",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"timeout",
")",
")",
"{",
"$",
"this",
"->",
"_write",
"(",
"sprintf",
"(",
"'reserve-with-timeout %d'",
",",
"$",
"timeout",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_write",
"(",
"'reserve'",
")",
";",
"}",
"$",
"status",
"=",
"strtok",
"(",
"$",
"this",
"->",
"_read",
"(",
")",
",",
"' '",
")",
";",
"switch",
"(",
"$",
"status",
")",
"{",
"case",
"'RESERVED'",
":",
"return",
"[",
"'id'",
"=>",
"(",
"integer",
")",
"strtok",
"(",
"' '",
")",
",",
"'body'",
"=>",
"$",
"this",
"->",
"_read",
"(",
"(",
"integer",
")",
"strtok",
"(",
"' '",
")",
")",
",",
"]",
";",
"case",
"'TIMED_OUT'",
":",
"return",
"false",
";",
"case",
"'DEADLINE_SOON'",
":",
"throw",
"new",
"DeadlineSoonException",
"(",
"'Reserve failed: '",
".",
"$",
"status",
")",
";",
"default",
":",
"throw",
"new",
"ServerException",
"(",
"'Reserve failed: '",
".",
"$",
"status",
")",
";",
"}",
"}"
] | Reserve a job (with a timeout).
@param int $timeout If given specifies number of seconds to wait for
a job. `0` returns immediately.
@return array|false `false` on error otherwise an array holding job id
and body. | [
"Reserve",
"a",
"job",
"(",
"with",
"a",
"timeout",
")",
"."
] | train | https://github.com/codeages/beanstalk-client/blob/097acad3cd9489413863f6cad86791216bc972e1/src/Client.php#L346-L368 |
codeages/beanstalk-client | src/Client.php | Client.delete | public function delete($id)
{
$this->_write(sprintf('delete %d', $id));
$status = $this->_read();
switch ($status) {
case 'DELETED':
return true;
case 'NOT_FOUND':
return false;
default:
throw new ServerException('Delete error: '.$status);
}
} | php | public function delete($id)
{
$this->_write(sprintf('delete %d', $id));
$status = $this->_read();
switch ($status) {
case 'DELETED':
return true;
case 'NOT_FOUND':
return false;
default:
throw new ServerException('Delete error: '.$status);
}
} | [
"public",
"function",
"delete",
"(",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"_write",
"(",
"sprintf",
"(",
"'delete %d'",
",",
"$",
"id",
")",
")",
";",
"$",
"status",
"=",
"$",
"this",
"->",
"_read",
"(",
")",
";",
"switch",
"(",
"$",
"status",
")",
"{",
"case",
"'DELETED'",
":",
"return",
"true",
";",
"case",
"'NOT_FOUND'",
":",
"return",
"false",
";",
"default",
":",
"throw",
"new",
"ServerException",
"(",
"'Delete error: '",
".",
"$",
"status",
")",
";",
"}",
"}"
] | Removes a job from the server entirely.
@param int $id The id of the job.
@return bool `false` on error, `true` on success. | [
"Removes",
"a",
"job",
"from",
"the",
"server",
"entirely",
"."
] | train | https://github.com/codeages/beanstalk-client/blob/097acad3cd9489413863f6cad86791216bc972e1/src/Client.php#L377-L390 |
codeages/beanstalk-client | src/Client.php | Client.release | public function release($id, $pri, $delay)
{
$this->_write(sprintf('release %d %d %d', $id, $pri, $delay));
$status = $this->_read();
switch ($status) {
case 'RELEASED':
case 'BURIED':
return true;
case 'NOT_FOUND':
return false;
default:
throw new ServerException('Release error: '.$status);
}
} | php | public function release($id, $pri, $delay)
{
$this->_write(sprintf('release %d %d %d', $id, $pri, $delay));
$status = $this->_read();
switch ($status) {
case 'RELEASED':
case 'BURIED':
return true;
case 'NOT_FOUND':
return false;
default:
throw new ServerException('Release error: '.$status);
}
} | [
"public",
"function",
"release",
"(",
"$",
"id",
",",
"$",
"pri",
",",
"$",
"delay",
")",
"{",
"$",
"this",
"->",
"_write",
"(",
"sprintf",
"(",
"'release %d %d %d'",
",",
"$",
"id",
",",
"$",
"pri",
",",
"$",
"delay",
")",
")",
";",
"$",
"status",
"=",
"$",
"this",
"->",
"_read",
"(",
")",
";",
"switch",
"(",
"$",
"status",
")",
"{",
"case",
"'RELEASED'",
":",
"case",
"'BURIED'",
":",
"return",
"true",
";",
"case",
"'NOT_FOUND'",
":",
"return",
"false",
";",
"default",
":",
"throw",
"new",
"ServerException",
"(",
"'Release error: '",
".",
"$",
"status",
")",
";",
"}",
"}"
] | Puts a reserved job back into the ready queue.
@param int $id The id of the job.
@param int $pri Priority to assign to the job.
@param int $delay Number of seconds to wait before putting the job in the ready queue.
@return bool `false` on error, `true` on success. | [
"Puts",
"a",
"reserved",
"job",
"back",
"into",
"the",
"ready",
"queue",
"."
] | train | https://github.com/codeages/beanstalk-client/blob/097acad3cd9489413863f6cad86791216bc972e1/src/Client.php#L401-L415 |
codeages/beanstalk-client | src/Client.php | Client.watch | public function watch($tube)
{
$this->_watchingTubes[$tube] = true;
$this->_write(sprintf('watch %s', $tube));
$status = strtok($this->_read(), ' ');
switch ($status) {
case 'WATCHING':
return (integer) strtok(' ');
default:
throw new ServerException('Watch error: '.$status);
}
} | php | public function watch($tube)
{
$this->_watchingTubes[$tube] = true;
$this->_write(sprintf('watch %s', $tube));
$status = strtok($this->_read(), ' ');
switch ($status) {
case 'WATCHING':
return (integer) strtok(' ');
default:
throw new ServerException('Watch error: '.$status);
}
} | [
"public",
"function",
"watch",
"(",
"$",
"tube",
")",
"{",
"$",
"this",
"->",
"_watchingTubes",
"[",
"$",
"tube",
"]",
"=",
"true",
";",
"$",
"this",
"->",
"_write",
"(",
"sprintf",
"(",
"'watch %s'",
",",
"$",
"tube",
")",
")",
";",
"$",
"status",
"=",
"strtok",
"(",
"$",
"this",
"->",
"_read",
"(",
")",
",",
"' '",
")",
";",
"switch",
"(",
"$",
"status",
")",
"{",
"case",
"'WATCHING'",
":",
"return",
"(",
"integer",
")",
"strtok",
"(",
"' '",
")",
";",
"default",
":",
"throw",
"new",
"ServerException",
"(",
"'Watch error: '",
".",
"$",
"status",
")",
";",
"}",
"}"
] | Adds the named tube to the watch list for the current connection.
@param string $tube Name of tube to watch.
@return int|bool `false` on error otherwise number of tubes in watch list. | [
"Adds",
"the",
"named",
"tube",
"to",
"the",
"watch",
"list",
"for",
"the",
"current",
"connection",
"."
] | train | https://github.com/codeages/beanstalk-client/blob/097acad3cd9489413863f6cad86791216bc972e1/src/Client.php#L470-L482 |
codeages/beanstalk-client | src/Client.php | Client._peekRead | protected function _peekRead()
{
$status = strtok($this->_read(), ' ');
switch ($status) {
case 'FOUND':
return [
'id' => (integer) strtok(' '),
'body' => $this->_read((integer) strtok(' ')),
];
case 'NOT_FOUND':
return false;
default:
throw new ServerException('Peek error: '.$status);
}
} | php | protected function _peekRead()
{
$status = strtok($this->_read(), ' ');
switch ($status) {
case 'FOUND':
return [
'id' => (integer) strtok(' '),
'body' => $this->_read((integer) strtok(' ')),
];
case 'NOT_FOUND':
return false;
default:
throw new ServerException('Peek error: '.$status);
}
} | [
"protected",
"function",
"_peekRead",
"(",
")",
"{",
"$",
"status",
"=",
"strtok",
"(",
"$",
"this",
"->",
"_read",
"(",
")",
",",
"' '",
")",
";",
"switch",
"(",
"$",
"status",
")",
"{",
"case",
"'FOUND'",
":",
"return",
"[",
"'id'",
"=>",
"(",
"integer",
")",
"strtok",
"(",
"' '",
")",
",",
"'body'",
"=>",
"$",
"this",
"->",
"_read",
"(",
"(",
"integer",
")",
"strtok",
"(",
"' '",
")",
")",
",",
"]",
";",
"case",
"'NOT_FOUND'",
":",
"return",
"false",
";",
"default",
":",
"throw",
"new",
"ServerException",
"(",
"'Peek error: '",
".",
"$",
"status",
")",
";",
"}",
"}"
] | Handles response for all peek methods.
@return string|bool `false` on error otherwise the body of the job. | [
"Handles",
"response",
"for",
"all",
"peek",
"methods",
"."
] | train | https://github.com/codeages/beanstalk-client/blob/097acad3cd9489413863f6cad86791216bc972e1/src/Client.php#L563-L578 |
codeages/beanstalk-client | src/Client.php | Client.kick | public function kick($bound)
{
$this->_write(sprintf('kick %d', $bound));
$status = strtok($this->_read(), ' ');
switch ($status) {
case 'KICKED':
return (integer) strtok(' ');
default:
throw new ServerException('Kick error: '.$status);
}
} | php | public function kick($bound)
{
$this->_write(sprintf('kick %d', $bound));
$status = strtok($this->_read(), ' ');
switch ($status) {
case 'KICKED':
return (integer) strtok(' ');
default:
throw new ServerException('Kick error: '.$status);
}
} | [
"public",
"function",
"kick",
"(",
"$",
"bound",
")",
"{",
"$",
"this",
"->",
"_write",
"(",
"sprintf",
"(",
"'kick %d'",
",",
"$",
"bound",
")",
")",
";",
"$",
"status",
"=",
"strtok",
"(",
"$",
"this",
"->",
"_read",
"(",
")",
",",
"' '",
")",
";",
"switch",
"(",
"$",
"status",
")",
"{",
"case",
"'KICKED'",
":",
"return",
"(",
"integer",
")",
"strtok",
"(",
"' '",
")",
";",
"default",
":",
"throw",
"new",
"ServerException",
"(",
"'Kick error: '",
".",
"$",
"status",
")",
";",
"}",
"}"
] | Moves jobs into the ready queue (applies to the current tube).
If there are buried jobs those get kicked only otherwise delayed
jobs get kicked.
@param int $bound Upper bound on the number of jobs to kick.
@return int|bool False on error otherwise number of jobs kicked. | [
"Moves",
"jobs",
"into",
"the",
"ready",
"queue",
"(",
"applies",
"to",
"the",
"current",
"tube",
")",
"."
] | train | https://github.com/codeages/beanstalk-client/blob/097acad3cd9489413863f6cad86791216bc972e1/src/Client.php#L590-L601 |
codeages/beanstalk-client | src/Client.php | Client.kickJob | public function kickJob($id)
{
$this->_write(sprintf('kick-job %d', $id));
$status = strtok($this->_read(), ' ');
switch ($status) {
case 'KICKED':
return true;
case 'NOT_FOUND':
return false;
default:
throw new ServerException('Kick error: '.$status);
}
} | php | public function kickJob($id)
{
$this->_write(sprintf('kick-job %d', $id));
$status = strtok($this->_read(), ' ');
switch ($status) {
case 'KICKED':
return true;
case 'NOT_FOUND':
return false;
default:
throw new ServerException('Kick error: '.$status);
}
} | [
"public",
"function",
"kickJob",
"(",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"_write",
"(",
"sprintf",
"(",
"'kick-job %d'",
",",
"$",
"id",
")",
")",
";",
"$",
"status",
"=",
"strtok",
"(",
"$",
"this",
"->",
"_read",
"(",
")",
",",
"' '",
")",
";",
"switch",
"(",
"$",
"status",
")",
"{",
"case",
"'KICKED'",
":",
"return",
"true",
";",
"case",
"'NOT_FOUND'",
":",
"return",
"false",
";",
"default",
":",
"throw",
"new",
"ServerException",
"(",
"'Kick error: '",
".",
"$",
"status",
")",
";",
"}",
"}"
] | This is a variant of the kick command that operates with a single
job identified by its job id. If the given job id exists and is in a
buried or delayed state, it will be moved to the ready queue of the
the same tube where it currently belongs.
@param int $id The job id.
@return bool `false` on error `true` otherwise. | [
"This",
"is",
"a",
"variant",
"of",
"the",
"kick",
"command",
"that",
"operates",
"with",
"a",
"single",
"job",
"identified",
"by",
"its",
"job",
"id",
".",
"If",
"the",
"given",
"job",
"id",
"exists",
"and",
"is",
"in",
"a",
"buried",
"or",
"delayed",
"state",
"it",
"will",
"be",
"moved",
"to",
"the",
"ready",
"queue",
"of",
"the",
"the",
"same",
"tube",
"where",
"it",
"currently",
"belongs",
"."
] | train | https://github.com/codeages/beanstalk-client/blob/097acad3cd9489413863f6cad86791216bc972e1/src/Client.php#L613-L626 |
codeages/beanstalk-client | src/Client.php | Client.listTubeUsed | public function listTubeUsed()
{
$this->_write('list-tube-used');
$status = strtok($this->_read(), ' ');
switch ($status) {
case 'USING':
return strtok(' ');
default:
throw new ServerException('List tube used error: '.$status);
}
} | php | public function listTubeUsed()
{
$this->_write('list-tube-used');
$status = strtok($this->_read(), ' ');
switch ($status) {
case 'USING':
return strtok(' ');
default:
throw new ServerException('List tube used error: '.$status);
}
} | [
"public",
"function",
"listTubeUsed",
"(",
")",
"{",
"$",
"this",
"->",
"_write",
"(",
"'list-tube-used'",
")",
";",
"$",
"status",
"=",
"strtok",
"(",
"$",
"this",
"->",
"_read",
"(",
")",
",",
"' '",
")",
";",
"switch",
"(",
"$",
"status",
")",
"{",
"case",
"'USING'",
":",
"return",
"strtok",
"(",
"' '",
")",
";",
"default",
":",
"throw",
"new",
"ServerException",
"(",
"'List tube used error: '",
".",
"$",
"status",
")",
";",
"}",
"}"
] | Returns the tube currently being used by the producer.
@return string|bool `false` on error otherwise a string with the name of the tube. | [
"Returns",
"the",
"tube",
"currently",
"being",
"used",
"by",
"the",
"producer",
"."
] | train | https://github.com/codeages/beanstalk-client/blob/097acad3cd9489413863f6cad86791216bc972e1/src/Client.php#L687-L698 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.