idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
46,200 | private function _escape ( $ string , $ escapeChar ) { if ( $ escapeChar ) { $ this -> buffer = $ escapeChar ; return preg_replace_callback ( '/\\' . $ escapeChar . '(.)' . '/' , array ( & $ this , '_escapeBis' ) , $ string ) ; } else { return $ string ; } } | encode escaped characters |
46,201 | private function _unescape ( $ string , $ escapeChar ) { if ( $ escapeChar ) { $ regexp = '/' . '\\' . $ escapeChar . '/' ; $ this -> buffer = array ( 'escapeChar' => $ escapeChar , 'i' => 0 ) ; return preg_replace_callback ( $ regexp , array ( & $ this , '_unescapeBis' ) , $ string ) ; } else { return $ string ; } } | decode escaped characters |
46,202 | protected function pciconf ( ) { $ arrResults = array ( ) ; $ intS = 0 ; if ( CommonFunctions :: executeProgram ( "pciconf" , "-lv" , $ strBuf , PSI_DEBUG ) ) { $ arrTemp = array ( ) ; $ arrBlocks = preg_split ( "/\n\S/" , $ strBuf , - 1 , PREG_SPLIT_NO_EMPTY ) ; foreach ( $ arrBlocks as $ strBlock ) { $ arrLines = pre... | parsing the output of pciconf command |
46,203 | protected function usb ( ) { foreach ( $ this -> readdmesg ( ) as $ line ) { if ( preg_match ( '/^(u[a-z]+[0-9]+): <([^,]*)(.*)> on (usbus[0-9]+)/' , $ line , $ ar_buf ) ) { $ dev = new HWDevice ( ) ; $ dev -> setName ( $ ar_buf [ 2 ] ) ; $ this -> sys -> setUSBDevices ( $ dev ) ; } } } | USB devices get the ide device information out of dmesg |
46,204 | public function equals ( HWDevice $ dev ) { if ( $ dev -> getName ( ) === $ this -> _name && $ dev -> getCapacity ( ) === $ this -> _capacity && $ dev -> getManufacturer ( ) === $ this -> _manufacturer && $ dev -> getProduct ( ) === $ this -> _product && $ dev -> getSerial ( ) === $ this -> _serial ) { return true ; } ... | compare a given device with the internal one |
46,205 | private function _getconfig ( ) { if ( ( ! defined ( 'PSI_PLUGIN_' . strtoupper ( $ this -> _plugin_name ) . '_ACCESS' ) ) && ( ! defined ( 'PSI_PLUGIN_' . strtoupper ( $ this -> _plugin_name ) . '_FILE' ) ) && ( ! defined ( 'PSI_PLUGIN_' . strtoupper ( $ this -> _plugin_name ) . '_SHOW_SERIAL' ) ) ) { $ this -> global... | read the plugin configuration file if we have one in the plugin directory |
46,206 | private function _checkfiles ( ) { if ( ! file_exists ( $ this -> _plugin_base . "js/" . strtolower ( $ this -> _plugin_name ) . ".js" ) ) { $ this -> global_error -> addError ( "file_exists(" . $ this -> _plugin_base . "js/" . strtolower ( $ this -> _plugin_name ) . ".js)" , "JS-File for Plugin '" . $ this -> _plugin_... | check if there is a default translation file availabe and also the required js file for appending the content of the plugin to the main webpage |
46,207 | private function _createXml ( $ enc ) { $ dom = new DOMDocument ( '1.0' , 'UTF-8' ) ; $ root = $ dom -> createElement ( "Plugin_" . $ this -> _plugin_name ) ; $ dom -> appendChild ( $ root ) ; $ this -> xml = new SimpleXMLExtended ( simplexml_import_dom ( $ dom ) , $ enc ) ; } | create the xml template where plugin information are added to |
46,208 | private function _get_Win32_OperatingSystem ( ) { if ( $ this -> _Win32_OperatingSystem === null ) $ this -> _Win32_OperatingSystem = CommonFunctions :: getWMI ( $ this -> _wmi , 'Win32_OperatingSystem' , array ( 'CodeSet' , 'Locale' , 'LastBootUpTime' , 'LocalDateTime' , 'Version' , 'ServicePackMajorVersion' , 'Captio... | reads the data from WMI Win32_OperatingSystem |
46,209 | private function _get_Win32_ComputerSystem ( ) { if ( $ this -> _Win32_ComputerSystem === null ) $ this -> _Win32_ComputerSystem = CommonFunctions :: getWMI ( $ this -> _wmi , 'Win32_ComputerSystem' , array ( 'Name' , 'Manufacturer' , 'Model' ) ) ; return $ this -> _Win32_ComputerSystem ; } | reads the data from WMI Win32_ComputerSystem |
46,210 | private function _get_Win32_Processor ( ) { if ( $ this -> _Win32_Processor === null ) $ this -> _Win32_Processor = CommonFunctions :: getWMI ( $ this -> _wmi , 'Win32_Processor' , array ( 'LoadPercentage' , 'AddressWidth' , 'Name' , 'L2CacheSize' , 'L3CacheSize' , 'CurrentClockSpeed' , 'ExtClock' , 'NumberOfCores' , '... | reads the data from WMI Win32_Processor |
46,211 | private function _get_Win32_PerfFormattedData_PerfOS_Processor ( ) { if ( $ this -> _Win32_PerfFormattedData_PerfOS_Processor === null ) { $ cpubuffer = CommonFunctions :: getWMI ( $ this -> _wmi , 'Win32_PerfFormattedData_PerfOS_Processor' , array ( 'Name' , 'PercentProcessorTime' ) ) ; $ this -> _Win32_PerfFormattedD... | reads the data from WMI Win32_PerfFormattedData_PerfOS_Processor |
46,212 | private function _get_systeminfo ( ) { if ( $ this -> _systeminfo === null ) CommonFunctions :: executeProgram ( 'systeminfo' , '' , $ this -> _systeminfo , false ) ; return $ this -> _systeminfo ; } | reads the data from systeminfo |
46,213 | private function _getCodeSet ( ) { $ buffer = $ this -> _get_Win32_OperatingSystem ( ) ; if ( ! $ buffer ) { if ( CommonFunctions :: executeProgram ( 'reg' , 'query HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Nls\\CodePage /v ACP' , $ strBuf , false ) && ( strlen ( $ strBuf ) > 0 ) && preg_match ( "/^\s*ACP... | store the codepage of the os for converting some strings to utf - 8 |
46,214 | protected function _pci ( ) { if ( CommonFunctions :: executeProgram ( 'listdev' , '' , $ bufr , PSI_DEBUG ) ) { $ devices = preg_split ( "/^device /m" , $ bufr , - 1 , PREG_SPLIT_NO_EMPTY ) ; foreach ( $ devices as $ device ) { $ ar_buf = preg_split ( "/\n/" , $ device ) ; if ( count ( $ ar_buf ) >= 3 ) { if ( preg_ma... | PCI devices get the pci device information |
46,215 | protected function _usb ( ) { if ( CommonFunctions :: executeProgram ( 'listusb' , '' , $ bufr , PSI_DEBUG ) ) { $ devices = preg_split ( "/\n/" , $ bufr ) ; foreach ( $ devices as $ device ) { if ( preg_match ( "/^\S+\s+\S+\s+\"(.*)\"\s+\"(.*)\"/" , $ device , $ ar_buf ) ) { $ dev = new HWDevice ( ) ; $ dev -> setName... | USB devices get the usb device information |
46,216 | private function process_inarray ( $ needle , $ haystack ) { foreach ( $ haystack as $ stalk ) { if ( $ needle === $ stalk [ 0 ] ) { return true ; } } return false ; } | checks an array if process name is in |
46,217 | private function getUprecords ( ) { $ result = array ( ) ; $ i = 0 ; foreach ( $ this -> _lines as $ line ) { if ( ( $ i > 1 ) and ( strpos ( $ line , '---' ) === false ) ) { $ buffer = preg_split ( "/\s*[ |]\s+/" , ltrim ( ltrim ( $ line , '->' ) , ' ' ) ) ; if ( defined ( 'PSI_PLUGIN_UPRECORDS_SHORT_MODE' ) && ( PSI_... | get uprecords information |
46,218 | private function _distroicon ( ) { if ( extension_loaded ( 'pfSense' ) && CommonFunctions :: rfts ( '/etc/version' , $ version , 1 , 4096 , false ) && ( trim ( $ version ) != '' ) ) { $ this -> sys -> setDistribution ( 'pfSense ' . trim ( $ version ) ) ; $ this -> sys -> setDistributionIcon ( 'pfSense.png' ) ; } else {... | get icon name and distro extended check |
46,219 | private function _memoryadditional ( ) { $ pagesize = $ this -> grabkey ( "hw.pagesize" ) ; $ this -> sys -> setMemCache ( $ this -> grabkey ( "vm.stats.vm.v_cache_count" ) * $ pagesize ) ; $ this -> sys -> setMemApplication ( ( $ this -> grabkey ( "vm.stats.vm.v_active_count" ) + $ this -> grabkey ( "vm.stats.vm.v_wir... | extend the memory information with additional values |
46,220 | private function _addchild ( $ child , SimpleXMLExtended $ xml , & $ positions ) { foreach ( $ child as $ key => $ value ) { $ xmlnode = $ xml -> addChild ( "Process" ) ; if ( isset ( $ value [ 0 ] ) ) { array_push ( $ positions , $ value [ 0 ] ) ; $ xmlnode -> addAttribute ( 'PID' , $ value [ 0 ] ) ; $ parentid = arra... | recursive function to allow appending child processes to a parent process |
46,221 | public function getJsonString ( ) { if ( defined ( 'PSI_JSON_ISSUE' ) && ( PSI_JSON_ISSUE ) ) { return json_encode ( simplexml_load_string ( str_replace ( ">" , ">\n" , $ this -> getXMLString ( ) ) ) ) ; } else { return json_encode ( simplexml_load_string ( $ this -> getXMLString ( ) ) ) ; } } | get json string |
46,222 | public function setOutputFormat ( $ outputFormat ) { if ( ! $ this -> isValidOutputFormat ( $ outputFormat ) ) { throw new InvalidFormat ( "Format {$outputFormat} is not supported" ) ; } $ this -> outputFormat = $ outputFormat ; return $ this ; } | Set the output format . |
46,223 | public function setPage ( $ page ) { if ( $ page > $ this -> getNumberOfPages ( ) || $ page < 1 ) { throw new PageDoesNotExist ( "Page {$page} does not exist" ) ; } $ this -> page = $ page ; return $ this ; } | Set the page number that should be rendered . |
46,224 | public function saveImage ( $ pathToImage ) { if ( is_dir ( $ pathToImage ) ) { $ pathToImage = rtrim ( $ pathToImage , '\/' ) . DIRECTORY_SEPARATOR . $ this -> page . '.' . $ this -> outputFormat ; } $ imageData = $ this -> getImageData ( $ pathToImage ) ; return file_put_contents ( $ pathToImage , $ imageData ) !== f... | Save the image to the given path . |
46,225 | public function saveAllPagesAsImages ( $ directory , $ prefix = '' ) { $ numberOfPages = $ this -> getNumberOfPages ( ) ; if ( $ numberOfPages === 0 ) { return [ ] ; } return array_map ( function ( $ pageNumber ) use ( $ directory , $ prefix ) { $ this -> setPage ( $ pageNumber ) ; $ destination = "{$directory}/{$prefi... | Save the file as images to the given directory . |
46,226 | public function getImageData ( $ pathToImage ) { $ this -> imagick = new Imagick ( ) ; $ this -> imagick -> setResolution ( $ this -> resolution , $ this -> resolution ) ; if ( $ this -> colorspace !== null ) { $ this -> imagick -> setColorspace ( $ this -> colorspace ) ; } if ( $ this -> compressionQuality !== null ) ... | Return raw image data . |
46,227 | protected function getRemoteImageData ( $ pathToImage ) { $ this -> imagick -> readImage ( $ this -> pdfFile ) ; $ this -> imagick -> setIteratorIndex ( $ this -> page - 1 ) ; if ( is_int ( $ this -> layerMethod ) ) { $ this -> imagick = $ this -> imagick -> mergeImageLayers ( $ this -> layerMethod ) ; } $ this -> imag... | Return remote raw image data . |
46,228 | protected function determineOutputFormat ( $ pathToImage ) { $ outputFormat = pathinfo ( $ pathToImage , PATHINFO_EXTENSION ) ; if ( $ this -> outputFormat != '' ) { $ outputFormat = $ this -> outputFormat ; } $ outputFormat = strtolower ( $ outputFormat ) ; if ( ! $ this -> isValidOutputFormat ( $ outputFormat ) ) { $... | Determine in which format the image must be rendered . |
46,229 | protected function getFullNamespace ( $ type , $ strNs ) { if ( $ type !== '' && $ type { 0 } != '\\' ) { if ( $ strNs != '' ) { $ type = '\\' . $ strNs . '\\' . $ type ; } } return $ type ; } | Convert a type name to a fully namespaced type name . |
46,230 | protected function checkMissingData ( $ providedProperties , ReflectionClass $ rc ) { foreach ( $ rc -> getProperties ( ) as $ property ) { $ rprop = $ rc -> getProperty ( $ property -> name ) ; $ docblock = $ rprop -> getDocComment ( ) ; $ annotations = $ this -> parseAnnotations ( $ docblock ) ; if ( isset ( $ annota... | Check required properties exist in json |
46,231 | public function mapArray ( $ json , $ array , $ class = null , $ parent_key = '' ) { foreach ( $ json as $ key => $ jvalue ) { if ( $ class === null ) { $ array [ $ key ] = $ jvalue ; } else if ( $ this -> isArrayOfType ( $ class ) ) { $ array [ $ key ] = $ this -> mapArray ( $ jvalue , array ( ) , substr ( $ class , 0... | Map an array |
46,232 | protected function getSafeName ( $ name ) { if ( strpos ( $ name , '-' ) !== false ) { $ name = $ this -> getCamelCaseName ( $ name ) ; } return $ name ; } | Since hyphens cannot be used in variables we have to uppercase them . |
46,233 | protected function setProperty ( $ object , $ accessor , $ value ) { if ( ! $ accessor -> isPublic ( ) && $ this -> bIgnoreVisibility ) { $ accessor -> setAccessible ( true ) ; } if ( $ accessor instanceof ReflectionProperty ) { $ accessor -> setValue ( $ object , $ value ) ; } else { $ accessor -> invoke ( $ object , ... | Set a property on a given object to a given value . |
46,234 | public function createInstance ( $ class , $ useParameter = false , $ jvalue = null ) { if ( isset ( $ this -> classMap [ $ class ] ) ) { if ( is_callable ( $ mapper = $ this -> classMap [ $ class ] ) ) { $ class = $ mapper ( $ class , $ jvalue ) ; } else { $ class = $ this -> classMap [ $ class ] ; } } if ( $ useParam... | Create a new object of the given type . |
46,235 | protected function isSimpleType ( $ type ) { return $ type == 'string' || $ type == 'boolean' || $ type == 'bool' || $ type == 'integer' || $ type == 'int' || $ type == 'double' || $ type == 'float' || $ type == 'array' || $ type == 'object' ; } | Checks if the given type is a simple type |
46,236 | protected function isObjectOfSameType ( $ type , $ value ) { if ( false === is_object ( $ value ) ) { return false ; } return is_a ( $ value , $ type ) ; } | Checks if the object is of this type or has this type as one of its parents |
46,237 | protected function doLoad ( $ content , FilterInterface $ additionalFilter = null ) { $ filter = clone $ this -> filters ; if ( $ additionalFilter ) { $ filter -> ensure ( $ additionalFilter ) ; } $ asset = clone $ this ; $ asset -> setContent ( $ content ) ; $ filter -> filterLoad ( $ asset ) ; $ this -> content = $ a... | Encapsulates asset loading logic . |
46,238 | private static function getCacheKey ( AssetInterface $ asset , FilterInterface $ additionalFilter = null , $ salt = '' ) { if ( $ additionalFilter ) { $ asset = clone $ asset ; $ asset -> ensureFilter ( $ additionalFilter ) ; } $ cacheKey = $ asset -> getSourceRoot ( ) ; $ cacheKey .= $ asset -> getSourcePath ( ) ; $ c... | Returns a cache key for the current asset . |
46,239 | public function get ( $ name ) { if ( ! isset ( $ this -> assets [ $ name ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'There is no "%s" asset.' , $ name ) ) ; } return $ this -> assets [ $ name ] ; } | Gets an asset by name . |
46,240 | public function set ( $ name , AssetInterface $ asset ) { if ( ! ctype_alnum ( str_replace ( '_' , '' , $ name ) ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The name "%s" is invalid.' , $ name ) ) ; } $ this -> assets [ $ name ] = $ asset ; } | Registers an asset to the current asset manager . |
46,241 | public function setLoader ( $ alias , FormulaLoaderInterface $ loader ) { $ this -> loaders [ $ alias ] = $ loader ; $ this -> loaded = false ; } | Adds a loader to the asset manager . |
46,242 | public function addResource ( ResourceInterface $ resource , $ loader ) { $ this -> resources [ $ loader ] [ ] = $ resource ; $ this -> loaded = false ; } | Adds a resource to the asset manager . |
46,243 | public function getResources ( ) { $ resources = array ( ) ; foreach ( $ this -> resources as $ r ) { $ resources = array_merge ( $ resources , $ r ) ; } return $ resources ; } | Returns an array of resources . |
46,244 | public function hasFormula ( $ name ) { if ( ! $ this -> loaded ) { $ this -> load ( ) ; } return isset ( $ this -> formulae [ $ name ] ) ; } | Checks for an asset formula . |
46,245 | public function getFormula ( $ name ) { if ( ! $ this -> loaded ) { $ this -> load ( ) ; } if ( ! isset ( $ this -> formulae [ $ name ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'There is no "%s" formula.' , $ name ) ) ; } return $ this -> formulae [ $ name ] ; } | Returns an asset s formula . |
46,246 | public function load ( ) { if ( $ this -> loading ) { return ; } if ( $ diff = array_diff ( array_keys ( $ this -> resources ) , array_keys ( $ this -> loaders ) ) ) { throw new \ LogicException ( 'The following loader(s) are not registered: ' . implode ( ', ' , $ diff ) ) ; } $ this -> loading = true ; foreach ( $ thi... | Loads formulae from resources . |
46,247 | public function accept ( ) { $ asset = $ this -> getInnerIterator ( ) -> current ( true ) ; $ duplicate = false ; if ( in_array ( $ asset , $ this -> visited , true ) ) { $ duplicate = true ; } else { $ this -> visited [ ] = $ asset ; } $ sourceRoot = $ asset -> getSourceRoot ( ) ; $ sourcePath = $ asset -> getSourcePa... | Determines whether the current asset is a duplicate . |
46,248 | public static function removeDirectory ( $ directory ) { $ inner = new \ RecursiveDirectoryIterator ( $ directory , \ FilesystemIterator :: SKIP_DOTS ) ; $ outer = new \ RecursiveIteratorIterator ( $ inner , \ RecursiveIteratorIterator :: SELF_FIRST ) ; foreach ( $ outer as $ file ) { if ( $ file -> isFile ( ) ) { unli... | Recursively removes a directory from the filesystem . |
46,249 | public static function createThrowAwayDirectory ( $ prefix ) { $ directory = self :: getTemporaryDirectory ( ) . DIRECTORY_SEPARATOR . uniqid ( 'assetic_' . $ prefix ) ; mkdir ( $ directory ) ; return $ directory ; } | Creates a throw - away directory . |
46,250 | public function current ( $ raw = false ) { $ asset = current ( $ this -> assets ) ; if ( $ raw ) { return $ asset ; } if ( ! isset ( $ this -> clones [ $ asset ] ) ) { $ clone = $ this -> clones [ $ asset ] = clone $ asset ; $ name = sprintf ( '%s_%d' , pathinfo ( $ asset -> getSourcePath ( ) , PATHINFO_FILENAME ) ? :... | Returns a copy of the current asset with filters and a target URL applied . |
46,251 | public function ensure ( FilterInterface $ filter ) { if ( $ filter instanceof \ Traversable ) { foreach ( $ filter as $ f ) { $ this -> ensure ( $ f ) ; } } elseif ( ! in_array ( $ filter , $ this -> filters , true ) ) { $ this -> filters [ ] = $ filter ; } } | Checks that the current collection contains the supplied filter . |
46,252 | public function getLastModified ( ) { if ( ! count ( $ this -> assets ) ) { return ; } $ mtime = 0 ; foreach ( $ this as $ asset ) { $ assetMtime = $ asset -> getLastModified ( ) ; if ( $ assetMtime > $ mtime ) { $ mtime = $ assetMtime ; } } return $ mtime ; } | Returns the highest last - modified value of all assets in the current collection . |
46,253 | public function set ( $ resource , $ value ) { $ path = $ this -> getSourcePath ( $ resource ) ; if ( ! is_dir ( $ dir = dirname ( $ path ) ) && false === @ mkdir ( $ dir , 0777 , true ) ) { throw new \ RuntimeException ( 'Unable to create directory ' . $ dir ) ; } if ( false === @ file_put_contents ( $ path , sprintf ... | Writes a value to a file . |
46,254 | public function get ( $ resource ) { $ path = $ this -> getSourcePath ( $ resource ) ; if ( ! file_exists ( $ path ) ) { throw new \ RuntimeException ( 'There is no cached value for ' . $ resource ) ; } return include $ path ; } | Loads and returns the value for the supplied cache key . |
46,255 | public function getTimestamp ( $ resource ) { $ path = $ this -> getSourcePath ( $ resource ) ; if ( ! file_exists ( $ path ) ) { throw new \ RuntimeException ( 'There is no cached value for ' . $ resource ) ; } if ( false === $ mtime = @ filemtime ( $ path ) ) { throw new \ RuntimeException ( 'Unable to determine file... | Returns a timestamp for when the cache was created . |
46,256 | protected function getRelativeName ( ResourceInterface $ file , ResourceInterface $ directory ) { return substr ( ( string ) $ file , strlen ( ( string ) $ directory ) ) ; } | Returns the relative version of a filename . |
46,257 | private function getFileResources ( ) { $ paths = array ( ) ; foreach ( $ this -> directories as $ directory ) { foreach ( $ directory as $ file ) { $ relative = $ this -> getRelativeName ( $ file , $ directory ) ; if ( ! isset ( $ paths [ $ relative ] ) ) { $ paths [ $ relative ] = $ file ; } } } return array_values (... | Performs the coalesce . |
46,258 | public static function resolve ( $ template , array $ vars , array $ values ) { $ map = array ( ) ; foreach ( $ vars as $ var ) { if ( false === strpos ( $ template , '{' . $ var . '}' ) ) { continue ; } if ( ! isset ( $ values [ $ var ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The template "%s" contains... | Resolves variable placeholders . |
46,259 | public static function filterCommentless ( $ content , $ callback ) { $ result = '' ; foreach ( preg_split ( static :: REGEX_COMMENTS , $ content , - 1 , PREG_SPLIT_DELIM_CAPTURE ) as $ part ) { if ( ! preg_match ( static :: REGEX_COMMENTS , $ part , $ match ) || $ part != $ match [ 0 ] ) { $ part = call_user_func ( $ ... | Filters each non - comment part through a callable . |
46,260 | private function applyWorkers ( AssetCollectionInterface $ asset ) { foreach ( $ asset as $ leaf ) { foreach ( $ this -> workers as $ worker ) { $ retval = $ worker -> process ( $ leaf , $ this ) ; if ( $ retval instanceof AssetInterface && $ leaf !== $ retval ) { $ asset -> replaceLeaf ( $ leaf , $ retval ) ; } } } fo... | Filters an asset collection through the factory workers . |
46,261 | private static function findRootDir ( $ path , array $ roots ) { foreach ( $ roots as $ root ) { if ( 0 === strpos ( $ path , $ root ) ) { return $ root ; } } } | Loops through the root directories and returns the first match . |
46,262 | public function getContent ( ) { $ content = array ( ) ; foreach ( $ this as $ resource ) { $ content [ ] = $ resource -> getContent ( ) ; } return implode ( "\n" , $ content ) ; } | Returns the combined content of all inner resources . |
46,263 | public function getQualifiedParentKeyName ( ) { if ( is_array ( $ this -> localKey ) ) { return array_map ( function ( $ k ) { return $ this -> parent -> getTable ( ) . '.' . $ k ; } , $ this -> localKey ) ; } else { return $ this -> parent -> getTable ( ) . '.' . $ this -> localKey ; } } | Get the fully qualified parent key name . |
46,264 | public function getForeignKeyName ( ) { $ key = $ this -> getQualifiedForeignKeyName ( ) ; if ( is_array ( $ key ) ) { return array_map ( function ( $ k ) { $ segments = explode ( '.' , $ k ) ; return $ segments [ count ( $ segments ) - 1 ] ; } , $ key ) ; } else { $ segments = explode ( '.' , $ key ) ; return $ segmen... | Get the plain foreign key . |
46,265 | protected function setForeignAttributesForCreate ( Model $ model ) { $ foreignKey = $ this -> getForeignKeyName ( ) ; $ parentKeyValue = $ this -> getParentKey ( ) ; if ( is_array ( $ foreignKey ) ) { foreach ( $ foreignKey as $ index => $ key ) { $ model -> setAttribute ( $ key , $ parentKeyValue [ $ index ] ) ; } } e... | Set the foreign ID for creating a related model . |
46,266 | protected function newBaseQueryBuilder ( ) { $ connection = $ this -> getConnection ( ) ; return new QueryBuilder ( $ connection , $ connection -> getQueryGrammar ( ) , $ connection -> getPostProcessor ( ) ) ; } | Configure Eloquent to use Compoships Query Builder |
46,267 | public function getQualifiedForeignKey ( ) { if ( is_array ( $ this -> foreignKey ) ) { return array_map ( function ( $ k ) { return $ this -> child -> getTable ( ) . '.' . $ k ; } , $ this -> foreignKey ) ; } else { return $ this -> child -> getTable ( ) . '.' . $ this -> foreignKey ; } } | Get the fully qualified foreign key of the relationship . |
46,268 | private function validateRelatedModel ( $ related ) { $ uses = class_uses_recursive ( $ related ) ; if ( ! array_key_exists ( 'Awobaz\Compoships\Compoships' , $ uses ) && ! is_subclass_of ( $ related , 'Awobaz\Compoships\Database\Eloquent\Model' ) ) { throw new InvalidUsageException ( "The related model '${related}' mu... | Validate the related model for Compoships compatibility |
46,269 | public function inSpan ( array $ spanOptions , callable $ callable , array $ arguments = [ ] ) { $ span = $ this -> startSpan ( $ spanOptions + [ 'sameProcessAsParentSpan' => ! empty ( $ this -> spans ) ] ) ; $ scope = $ this -> withSpan ( $ span ) ; try { return call_user_func_array ( $ callable , $ arguments ) ; } fi... | Instrument a callable by creating a Span that manages the startTime and endTime . |
46,270 | public function startSpan ( array $ spanOptions = [ ] ) { $ spanOptions += [ 'traceId' => $ this -> spanContext ( ) -> traceId ( ) , 'parentSpanId' => $ this -> spanContext ( ) -> spanId ( ) , 'startTime' => microtime ( true ) ] ; return new Span ( $ spanOptions ) ; } | Create a new Span . The start time is already set to the current time . The newly created span is not attached to the current context . |
46,271 | public function spanContext ( ) { $ context = Context :: current ( ) ; return new SpanContext ( $ context -> value ( 'traceId' ) , $ context -> value ( 'spanId' ) , $ context -> value ( 'enabled' ) , $ context -> value ( 'fromHeader' ) ) ; } | Returns the current SpanContext |
46,272 | public static function load ( ) { if ( ! extension_loaded ( 'opencensus' ) ) { trigger_error ( 'opencensus extension required to load Eloquent integrations.' , E_USER_WARNING ) ; return ; } opencensus_trace_method ( Builder :: class , 'getModels' , function ( $ builder ) { return [ 'name' => 'eloquent/get' , 'attribute... | Static method to add instrumentation to Eloquent ORM calls |
46,273 | public static function load ( ) { if ( ! extension_loaded ( 'opencensus' ) ) { trigger_error ( 'opencensus extension required to load mysqli integrations.' , E_USER_WARNING ) ; return ; } opencensus_trace_function ( 'mysqli_query' , function ( $ mysqli , $ query ) { return [ 'attributes' => [ 'query' => $ query ] , 'ki... | Static method to add instrumentation to mysql requests |
46,274 | public static function start ( ExporterInterface $ reporter , array $ options = [ ] ) { $ sampler = array_key_exists ( 'sampler' , $ options ) ? $ options [ 'sampler' ] : new AlwaysSampleSampler ( ) ; unset ( $ options [ 'sampler' ] ) ; $ propagator = array_key_exists ( 'propagator' , $ options ) ? $ options [ 'propaga... | Start a new trace session for this request . You should call this as early as possible for the most accurate results . |
46,275 | public static function inSpan ( array $ spanOptions , callable $ callable , array $ arguments = [ ] ) { if ( ! isset ( self :: $ instance ) ) { return call_user_func_array ( $ callable , $ arguments ) ; } return self :: $ instance -> inSpan ( $ spanOptions , $ callable , $ arguments ) ; } | Instrument a callable by creating a Span that manages the startTime and endTime . If an exception is thrown while executing the callable the exception will be caught the span will be closed and the exception will be re - thrown . |
46,276 | public static function startSpan ( array $ spanOptions = [ ] ) { if ( ! isset ( self :: $ instance ) ) { return new Span ( ) ; } return self :: $ instance -> startSpan ( $ spanOptions ) ; } | Explicitly start a new Span . You will need to attach the span and handle any thrown exceptions . |
46,277 | public static function spanContext ( ) { if ( ! isset ( self :: $ instance ) ) { return new SpanContext ( null , null , false ) ; } return self :: $ instance -> tracer ( ) -> spanContext ( ) ; } | Returns the current span context . |
46,278 | private function formatDate ( $ when = null ) { if ( ! $ when ) { $ when = $ this -> formatFloatTimeToDate ( microtime ( true ) ) ; } elseif ( is_numeric ( $ when ) ) { $ when = $ this -> formatFloatTimeToDate ( $ when ) ; } elseif ( ! $ when instanceof \ DateTimeInterface ) { throw new \ InvalidArgumentException ( 'In... | Handles parsing a \ DateTimeInterface object from a provided timestamp . |
46,279 | public static function encodeUnsigned ( string & $ buf , int $ x ) : int { $ offset = $ i = strlen ( $ buf ) ; while ( $ x >= 0x80 ) { $ buf [ $ i ++ ] = chr ( $ x | 0x80 ) ; $ x >>= 7 ; } $ buf [ $ i ++ ] = chr ( $ x ) ; return $ i - $ offset ; } | Varint encode as unsigned integer . |
46,280 | public static function encodeSigned ( string & $ buf , int $ x ) : int { $ ux = $ x << 1 ; if ( $ x < 0 ) { $ ux = ~ $ ux ; } return self :: encodeUnsigned ( $ buf , $ ux ) ; } | Varint encode as signed integer . |
46,281 | public static function decodeUnsigned ( string $ buf , int & $ x ) : int { $ x = 0 ; $ s = 0 ; for ( $ i = 0 ; $ i < strlen ( $ buf ) ; $ i ++ ) { $ b = ord ( $ buf [ $ i ] ) ; if ( $ b < 0x80 ) { if ( $ i > 9 || $ i == 9 && $ b > 1 ) { $ x = 0 ; return - ( $ i + 1 ) ; } $ x = $ x | $ b << $ s ; return $ i + 1 ; } $ x ... | Varint decode an unsigned integer . |
46,282 | public static function decodeSigned ( string $ buf , int & $ x ) : int { $ ux = 0 ; $ cnt = self :: decodeUnsigned ( $ buf , $ ux ) ; $ x = $ ux >> 1 ; if ( $ ux & 1 != 0 ) { $ x = ~ $ x ; } return $ cnt ; } | Varint decode a signed integer . |
46,283 | public static function load ( ) { if ( ! extension_loaded ( 'opencensus' ) ) { trigger_error ( 'opencensus extension required to load Memcached integrations.' , E_USER_WARNING ) ; return ; } opencensus_trace_method ( 'Memcached' , 'add' , [ self :: class , 'handleAttributes' ] ) ; opencensus_trace_method ( 'Memcached' ... | Static method to add instrumentation to memcache requests |
46,284 | public static function handleCasByKey ( $ memcached , $ casToken , $ serverKey , $ key ) { return [ 'attributes' => [ 'casToken' => $ casToken , 'serverKey' => $ serverKey , 'key' => $ key ] , 'kind' => Span :: KIND_CLIENT ] ; } | Handle converting the key and check and set token to attributes |
46,285 | public static function handleSetMultiByKey ( $ memcached , $ serverKey , $ items ) { return [ 'attributes' => [ 'serverKey' => $ serverKey , 'key' => implode ( ',' , array_keys ( $ items ) ) ] , 'kind' => Span :: KIND_CLIENT ] ; } | Extract key attribute from a setMulti command |
46,286 | public function putAttachment ( string $ key , string $ value ) : MeasurementInterface { $ this -> attachments [ $ key ] = $ value ; return $ this ; } | Add an Exemplar Attachment to our map . If the key already exists the existing Attachment in the map will be overriden with the new value . |
46,287 | public function record ( Context $ ctx = null , TagContext $ tags = null ) : bool { if ( count ( $ this -> measurements ) === 0 ) { return true ; } if ( $ ctx === null ) { $ ctx = Context :: current ( ) ; } $ recordTags = clone TagContext :: fromContext ( $ ctx ) ; if ( $ tags !== null ) { foreach ( $ tags -> tags ( ) ... | Record the Measurements Attachments and Tags found in the map . If Context is not explicitly provided the current Context is used . If a TagContext object is explicitly provided all tags found are inserted into the TagContext object found in Context . If a Tag with the same key already exists in the implicit TagContext... |
46,288 | public function stackTraceHashId ( ) { if ( ! isset ( $ this -> stackTraceHashId ) ) { $ md5 = md5 ( serialize ( $ this -> stackTrace ) ) ; $ this -> stackTraceHashId = substr ( $ md5 , 16 ) ; } return $ this -> stackTraceHashId ; } | Return a hash id for this span s stackTrace in hexadecimal |
46,289 | public static function getInstance ( ) : Stats { if ( self :: $ instance instanceof Stats ) { return self :: $ instance ; } self :: $ instance = new Stats ( ) ; self :: $ instance -> exporter = new NoopExporter ( ) ; return self :: $ instance ; } | Retrieve Stats instance . |
46,290 | final private function send ( string $ type , string $ msg = '' ) : bool { if ( $ this -> useExtension ) { return opencensus_core_send_to_daemonclient ( ord ( $ type ) , $ msg ) ; } $ start = microtime ( true ) ; $ maxEnd = $ start + $ this -> maxSendTime ; $ buf = self :: START_OF_MSG . $ type ; self :: encodeUnsigned... | Send message to daemon |
46,291 | final private static function encodeString ( string $ data ) : string { $ buf = '' ; self :: encodeUnsigned ( $ buf , strlen ( $ data ) ) ; return $ buf . $ data ; } | Encodes message payload by prefixing the message length as unsigned varint . |
46,292 | public static function create ( string $ value ) : TagValue { if ( strlen ( $ value ) > self :: MAX_LENGTH || ! self :: isPrintable ( $ value ) ) { throw new \ Exception ( "Invalid TagValue: $value" ) ; } return new self ( $ value ) ; } | Constructs a TagValue with the given string payload . |
46,293 | public function inject ( SpanContext $ context , $ container ) { $ header = $ this -> key ( ) ; $ value = $ this -> formatter -> serialize ( $ context ) ; if ( ! headers_sent ( ) ) { header ( "$header: $value" ) ; } return [ $ header => $ value ] ; } | Persists the current SpanContext back into the results of this request |
46,294 | public function onExit ( ) { $ this -> addCommonRequestAttributes ( $ this -> headers ) ; $ this -> scope -> close ( ) ; $ this -> exporter -> export ( $ this -> tracer -> spans ( ) ) ; } | The function registered as the shutdown function . Cleans up the trace and reports using the provided ExporterInterface . Adds additional attributes to the root span detected from the response . |
46,295 | public function shouldSample ( ) { foreach ( $ this -> samplers as $ sampler ) { if ( $ sampler -> shouldSample ( ) === false ) { return false ; } } return true ; } | Returns false if any provided sampler chooses not to sample this request . |
46,296 | public function shouldSample ( ) { if ( $ item = $ this -> cache -> getItem ( $ this -> key ) ) { if ( ( float ) $ item -> get ( ) > microtime ( true ) ) { return false ; } } $ item = new $ this -> cacheItemClass ( $ this -> key ) ; $ item -> set ( microtime ( true ) + 1.0 / $ this -> rate ) ; $ this -> cache -> save (... | Returns whether or not the request should be sampled . |
46,297 | private function defaultCache ( ) { if ( extension_loaded ( 'apcu' ) && class_exists ( '\\Cache\\Adapter\\Apcu\\ApcuCachePool' ) ) { return new \ Cache \ Adapter \ Apcu \ ApcuCachePool ( ) ; } elseif ( extension_loaded ( 'apc' ) && class_exists ( '\\Cache\\Adapter\\Apc\\ApcCachePool' ) ) { return new \ Cache \ Adapter ... | Detect a usable PSR - 6 cache implementation |
46,298 | public static function encode ( TagContext $ tagContext ) : string { $ str = self :: TAGS_VERSION_ID ; foreach ( $ tagContext -> tags ( ) as $ tag ) { $ str .= self :: KEYTYPE_STRING ; $ key = $ tag -> getKey ( ) -> getName ( ) ; $ buf = '' ; self :: encodeUnsigned ( $ buf , strlen ( $ key ) ) ; $ str .= $ buf . $ key ... | Encode the provided TagContext to our binary wire format . |
46,299 | public function inject ( SpanContext $ context , $ metadata ) { $ metadata [ $ this -> key ] = $ this -> formatter -> serialize ( $ context ) ; return $ metadata ; } | Persiste the current SpanContext back into the results of this request |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.