idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
6,900 | public static function max ( array $ real , int $ timePeriod = null ) : array { $ timePeriod = $ timePeriod ?? 30 ; $ return = trader_max ( $ real , $ timePeriod ) ; static :: checkForError ( ) ; return $ return ; } | Highest value over a specified period |
6,901 | public static function maxindex ( array $ real , int $ timePeriod = null ) : array { $ timePeriod = $ timePeriod ?? 30 ; $ return = trader_maxindex ( $ real , $ timePeriod ) ; static :: checkForError ( ) ; return $ return ; } | Index of highest value over a specified period |
6,902 | public static function midpoint ( array $ real , int $ timePeriod = null ) : array { $ timePeriod = $ timePeriod ?? 14 ; $ return = trader_midpoint ( $ real , $ timePeriod ) ; static :: checkForError ( ) ; return $ return ; } | MidPoint over period |
6,903 | public static function min ( array $ real , int $ timePeriod = null ) : array { $ timePeriod = $ timePeriod ?? 30 ; $ return = trader_min ( $ real , $ timePeriod ) ; static :: checkForError ( ) ; return $ return ; } | Lowest value over a specified period |
6,904 | public static function minindex ( array $ real , int $ timePeriod = null ) : array { $ timePeriod = $ timePeriod ?? 30 ; $ return = trader_minindex ( $ real , $ timePeriod ) ; static :: checkForError ( ) ; return $ return ; } | Index of lowest value over a specified period |
6,905 | public static function minmax ( array $ real , int $ timePeriod = null ) : array { $ timePeriod = $ timePeriod ?? 30 ; $ return = trader_minmax ( $ real , $ timePeriod ) ; static :: checkForError ( ) ; return $ return ; } | Lowest and highest values over a specified period |
6,906 | public static function minmaxindex ( array $ real , int $ timePeriod = null ) : array { $ timePeriod = $ timePeriod ?? 30 ; $ return = trader_minmaxindex ( $ real , $ timePeriod ) ; static :: checkForError ( ) ; return $ return ; } | Indexes of lowest and highest values over a specified period |
6,907 | public static function rsi ( array $ real , int $ timePeriod = null ) : array { $ timePeriod = $ timePeriod ?? 14 ; $ return = trader_rsi ( $ real , $ timePeriod ) ; static :: checkForError ( ) ; return $ return ; } | Relative Strength Index |
6,908 | public static function sma ( array $ real , int $ timePeriod = null ) : array { $ timePeriod = $ timePeriod ?? 30 ; $ return = trader_sma ( $ real , $ timePeriod ) ; static :: checkForError ( ) ; return $ return ; } | Simple Moving Average |
6,909 | public static function tema ( array $ real , int $ timePeriod = null ) : array { $ timePeriod = $ timePeriod ?? 30 ; $ return = trader_tema ( $ real , $ timePeriod ) ; static :: checkForError ( ) ; return $ return ; } | Triple Exponential Moving Average |
6,910 | public static function trima ( array $ real , int $ timePeriod = null ) : array { $ timePeriod = $ timePeriod ?? 30 ; $ return = trader_trima ( $ real , $ timePeriod ) ; static :: checkForError ( ) ; return $ return ; } | Triangular Moving Average |
6,911 | public static function tsf ( array $ real , int $ timePeriod = null ) : array { $ timePeriod = $ timePeriod ?? 14 ; $ return = trader_tsf ( $ real , $ timePeriod ) ; static :: checkForError ( ) ; return $ return ; } | Time Series Forecast |
6,912 | public static function wma ( array $ real , int $ timePeriod = null ) : array { $ timePeriod = $ timePeriod ?? 30 ; $ return = trader_wma ( $ real , $ timePeriod ) ; static :: checkForError ( ) ; return $ return ; } | Weighted Moving Average |
6,913 | private function hydrate ( ) : void { foreach ( $ this -> bag as $ key => $ value ) { if ( ! is_string ( $ value ) ) continue ; $ s = S :: create ( $ value ) ; if ( $ s -> startsWith ( Kernel :: PARTICLE_IN_ATTRIBUTEBAG_TPL [ 0 ] ) && $ s -> endsWith ( Kernel :: PARTICLE_IN_ATTRIBUTEBAG_TPL [ 1 ] ) ) { $ id = ( string ... | Hydrates the imported values . |
6,914 | public function create ( string $ category , string $ type , string $ uri ) : ServiceInterface { if ( ! self :: serviceExists ( $ category , $ type ) ) { throw new AdapterNonExistentException ( ) ; } $ service = $ this -> convertTypeToServiceClassName ( $ category , $ type ) ; return new $ service ( $ this -> kernel , ... | This function creates an instance of the valid service using the indicated adapter and returns the final object . |
6,915 | private function convertTypeToServiceClassName ( string $ category , string $ type ) : ? string { if ( class_exists ( $ type ) ) { return $ type ; } else { $ type = $ this -> kernel -> config ( ) -> namespaces -> services . ucfirst ( strtolower ( $ category ) ) . "\\Adapters\\" . ucfirst ( strtolower ( $ type ) ) ; if ... | This function converts a type name s such that it matches the standard service class name format . Please note this function doesn t necessarily check if this class name conforms the requirements to be a valid kernel service . |
6,916 | private function serviceExists ( string $ category , string $ type ) : bool { $ service_class = $ this -> convertTypeToServiceClassName ( $ category , $ type ) ; if ( is_null ( $ service_class ) ) return false ; $ interfaces = class_implements ( $ service_class ) ; if ( $ interfaces === false || ! is_array ( $ interfac... | Checks if the given type matches any valid service that implements appropriate service interfaces . |
6,917 | protected function getStates ( ) { if ( sizeof ( $ this -> states ) == 0 ) { $ this -> states = json_decode ( file_get_contents ( __DIR__ . '/Models/states.json' ) , true ) ; } return $ this -> states ; } | Get the states from the JSON file if it hasn t already been loaded . |
6,918 | public function getList ( $ sort = null ) { $ states = $ this -> getStates ( ) ; $ validSorts = [ 'iso_3166_2' , 'name' , 'country_code' , ] ; if ( ! is_null ( $ sort ) && in_array ( $ sort , $ validSorts ) ) { uasort ( $ states , function ( $ a , $ b ) use ( $ sort ) { if ( ! isset ( $ a [ $ sort ] ) && ! isset ( $ b ... | Returns a list of states |
6,919 | protected function processCacheRequest ( $ callback , $ method , $ args ) { $ key = $ this -> createCacheKey ( $ method , $ args ) ; return $ this -> getCache ( ) -> remember ( $ key , $ this -> getCacheTtl ( ) , $ callback ) ; } | Perform the query and cache if required . |
6,920 | public function onData ( $ data ) { if ( $ this -> secret !== null ) { mcrypt_generic_init ( $ this -> encryptor , $ this -> secret , $ this -> secret ) ; $ data = mdecrypt_generic ( $ this -> encryptor , $ data ) ; mcrypt_generic_deinit ( $ this -> encryptor ) ; } try { $ this -> packetBuffer .= $ data ; do { $ packet... | Called whenever there is data available on the stream |
6,921 | public function write ( $ data ) { if ( $ this -> secret !== null ) { mcrypt_generic_init ( $ this -> encryptor , $ this -> secret , $ this -> secret ) ; $ data = mcrypt_generic ( $ this -> encryptor , $ data ) ; mcrypt_generic_deinit ( $ this -> encryptor ) ; } return parent :: write ( $ data ) ; } | Override the base write to add encryption if we re in an encypted stage |
6,922 | public function enableAES ( $ secret ) { $ this -> secret = $ secret ; $ this -> encryptor = mcrypt_module_open ( MCRYPT_RIJNDAEL_128 , '' , MCRYPT_MODE_CFB , '' ) ; } | Enables encryption of the stream |
6,923 | public function onUpdate ( ) { if ( file_exists ( $ this -> savedTimestampPath ) ) { $ readTimestamp = file_get_contents ( $ this -> savedTimestampPath ) ; if ( $ readTimestamp != $ this -> savedTimestamp ) { foreach ( $ this -> clients as $ sendto ) { $ sendto -> send ( $ readTimestamp ) ; } $ this -> savedTimestamp =... | Sends out a message once a second to all connected clients containing the contents of latest - change . txt |
6,924 | public function getUrl ( $ file , $ type ) : string { if ( ! $ this -> checkPermission ( $ type ) ) { $ file = $ this -> noImage ; } $ filePath = $ this -> getCachePath ( $ file , $ type ) ; if ( file_exists ( $ filePath [ 'system' ] ) && ( time ( ) - filemtime ( $ filePath [ 'system' ] ) < $ this -> cacheTime ) ) { re... | Get image url |
6,925 | protected function getCachePath ( $ file , $ type ) : array { $ hash = md5 ( $ file . $ type ) ; if ( isset ( $ this -> config [ $ type ] ) ) { $ isTransparent = ArrayHelper :: getValue ( $ this -> config [ $ type ] , 'transparent' , false ) ; } else { $ isTransparent = false ; } $ cacheFileExt = $ isTransparent ? self... | Get image cache path |
6,926 | protected function checkPermission ( $ type ) { if ( isset ( $ this -> config [ $ type ] [ 'visible' ] ) ) { $ role = $ this -> config [ $ type ] [ 'visible' ] ; unset ( $ this -> config [ $ type ] [ 'visible' ] ) ; if ( ! Yii :: $ app -> getUser ( ) -> can ( $ role ) ) { return false ; } } return true ; } | Check permission for current user |
6,927 | public static function spellNumber ( $ number , $ language ) { if ( ! is_numeric ( $ number ) ) { throw new InvalidArgumentException ( 'Invalid number specified.' ) ; } return self :: get ( $ language ) -> parseInt ( intval ( $ number ) , false ) ; } | Convert a number into its linguistic representation . |
6,928 | public static function spellCurrency ( $ amount , $ language , $ currency , $ requireDecimal = true , $ spellDecimal = false ) { if ( ! is_numeric ( $ amount ) ) { throw new InvalidArgumentException ( 'Invalid number specified.' ) ; } if ( ! is_string ( $ currency ) ) { throw new InvalidArgumentException ( 'Invalid cur... | Convert currency to its linguistic representation . |
6,929 | public function verify ( int $ purpose = X509_PURPOSE_ANY ) : bool { $ chainFile = new TempFile ( ) ; $ chainFile -> setContent ( $ this ) ; $ certificate = $ this [ 0 ] ; return $ certificate -> checkPurpose ( $ purpose , [ ] , $ chainFile ) ; } | Verify the chain file . |
6,930 | public function onEncryptionResponsePacket ( EncryptionResponsePacket $ packet ) { if ( null === $ this -> verifyToken ) { $ this -> disconnectClient ( ( new DisconnectPacket ( ) ) -> setReason ( 'Packet received out of order' ) ) ; return ; } $ verifyToken = $ this -> certificate -> getPrivateKey ( ) -> decrypt ( $ pa... | Called on event LOGIN . EncryptionResponsePacket |
6,931 | public function onLoginStartPacket ( LoginStartPacket $ packet ) { $ this -> username = $ packet -> getUsername ( ) ; $ request = new EncryptionRequestPacket ( ) ; $ this -> serverID = $ request -> getRandomServerID ( ) ; $ this -> verifyToken = $ request -> getRandomServerID ( ) ; $ publicKey = $ this -> certificate -... | Called on event LOGIN . LoginStartPacket |
6,932 | public function onPingRequestPacket ( PingRequestPacket $ packet ) { $ ping = new PingResponsePacket ( ) ; $ ping -> setPingData ( $ packet -> getPingData ( ) ) ; $ this -> disconnectClient ( $ ping ) ; } | Called on event STATUS . PingRequestPacket |
6,933 | public function onStatusRequestPacket ( StatusRequestPacket $ packet ) { $ response = new StatusResponsePacket ( ) ; $ this -> emit ( 'status_request' , [ $ response ] ) ; $ this -> sendPacket ( $ response ) ; } | Called on STATUS . StatusRequestPacket |
6,934 | public function onHandshakePacket ( HandshakePacket $ packet ) { if ( $ packet -> getProtocolVersion ( ) != 47 ) { $ this -> disconnectClient ( ( new DisconnectPacket ( ) ) -> setReason ( 'Invalid Minecraft Version, use 1.8+' ) ) ; } $ this -> setStage ( $ packet -> getNextStage ( ) ) ; } | Called on HANDSHAKE . HandshakePacket |
6,935 | public static function checkRequirements ( ) { $ extensions = array ( 'curl' , 'json' ) ; foreach ( $ extensions as $ extension ) { if ( ! extension_loaded ( $ extension ) ) { throw new Exception \ RuntimeException ( 'You need the PHP ' . $ extension . ' extension in order to use EveryPay PHP Library' ) ; } } } | Check for needed requirements . |
6,936 | public static function setApiUrl ( $ url ) { $ apiUrl = filter_var ( $ url , FILTER_VALIDATE_URL ) ; if ( ! $ apiUrl ) { throw new Exception \ InvalidArgumentException ( 'API URL should be a valid url' ) ; } self :: $ apiUrl = rtrim ( $ url , '\\/' ) ; } | Set the API url for the request . |
6,937 | public static function reset ( ) { self :: $ apiKey = null ; self :: $ isTest = false ; self :: $ throwExceptions = false ; } | Reset Everypay class to its default values |
6,938 | public function export ( string $ password = NULL ) : string { $ status = openssl_pkey_export ( $ this -> getHandle ( ) , $ output , $ password ) ; if ( ! $ status ) { throw new RuntimeException ( OpenSSL :: getLastError ( ) ) ; } return $ output ; } | Export the key to a string as PEM . |
6,939 | public function exportToFile ( string $ filename , string $ password = NULL ) { $ status = openssl_pkey_export_to_file ( $ this -> getHandle ( ) , $ filename , $ password ) ; if ( ! $ status ) { throw new RuntimeException ( OpenSSL :: getLastError ( ) ) ; } } | Export the key to a file as PEM . |
6,940 | public function getFingerprint ( string $ algorithm = 'SHA1' ) : Hash { $ value = openssl_x509_fingerprint ( $ this -> getHandle ( ) , $ algorithm , TRUE ) ; if ( ! $ value ) { throw new RuntimeException ( OpenSSL :: getLastError ( ) ) ; } $ hash = new Hash ( $ algorithm ) ; $ hash -> setValue ( $ value ) ; return $ ha... | Get the fingerprint from certificate . |
6,941 | public function sanitize ( Request $ request , array $ ruleset ) { $ factory = app ( Sanitizer :: class ) -> rules ( $ ruleset ) ; return $ factory -> sanitize ( $ request -> all ( ) ) ; } | Run a sanitizer on a request object and return the sanitized data . |
6,942 | public function addProcess ( ProcessSpawnerEvent $ event ) { if ( ( bool ) Config :: getOption ( "plugins.reload.enabled" ) ) { if ( Console :: findCommand ( "w|watch" ) || Console :: findCommandOption ( "with-watch" ) ) { $ pathPHP = Console :: getPathPHP ( ) ; $ pathReload = __DIR__ . "/AutoReloadServer.php" ; $ comm... | Add command to initialize the websocket server |
6,943 | public function text ( $ text ) { if ( is_string ( $ text ) || settype ( $ text , 'string' ) !== false ) { return parent :: text ( $ this -> encodeString ( $ text ) ) ; } throw new \ InvalidArgumentException ( get_class ( $ this ) . ':text - Cannot cast passed value to string (did you forget to define a __toString on y... | Write Text into Attribute or Element |
6,944 | public function appendList ( array $ data , $ elementName , $ nsPrefix = null , $ nsUri = null ) { if ( null === $ nsPrefix ) { foreach ( $ data as $ value ) { $ this -> writeElement ( $ elementName , $ value ) ; } } else { foreach ( $ data as $ value ) { $ this -> writeElementNS ( $ nsPrefix , $ elementName , $ nsUri ... | Append an integer index array of values to this XML document |
6,945 | public function appendHash ( $ data , $ _previousKey = null ) { foreach ( $ data as $ key => $ value ) { $ this -> appendHashData ( $ key , $ value , $ _previousKey ) ; } return false ; } | Append an associative array or object to this XML document |
6,946 | protected function encodeString ( $ string ) { if ( $ this -> encoding === null ) { return $ string ; } $ detect = mb_detect_encoding ( $ string ) ; if ( is_string ( $ detect ) && $ detect === $ this -> encoding ) { return $ string ; } if ( is_bool ( $ detect ) ) { return $ string ; } return mb_convert_encoding ( $ str... | Apply requested encoding type to string |
6,947 | public function setLocale ( $ locale ) { $ file = __DIR__ . '/i18n/' . $ locale . '.json' ; if ( file_exists ( $ file ) ) { $ meta = json_decode ( file_get_contents ( $ file ) , true ) ; if ( is_array ( $ meta ) ) { $ this -> locale = $ meta ; return true ; } else { throw new LocaleParseErrorException ( 'Locale "' . $ ... | setLocale will set the locale . This is currently a 2 digit ISO country code |
6,948 | public function formatAddress ( $ html = false ) { if ( isset ( $ this -> locale [ 'fmt' ] ) ) { $ address_format = $ this -> locale [ 'fmt' ] ; $ formatted_address = $ address_format ; foreach ( $ this -> address_map as $ key => $ value ) { $ formatted_address = str_replace ( '%' . $ key , $ this -> input_map [ $ valu... | Return the formatted address using the locale set . Optionally return HTML or plain text |
6,949 | public function setAttribute ( $ attribute , $ value ) { if ( isset ( $ this -> input_map [ $ attribute ] ) ) { $ this -> input_map [ $ attribute ] = $ value ; return $ value ; } else { throw new AttributeInvalidException ( 'Attribute not supported by this library' ) ; } } | Set an address attribute . |
6,950 | public function getAttribute ( $ attribute ) { if ( isset ( $ this -> input_map [ $ attribute ] ) ) { return $ this -> input_map [ $ attribute ] ; } else { throw new AttributeInvalidException ( 'Attribute not supported by this library' ) ; } } | Get an address attribute . |
6,951 | public function validAddressPieces ( ) { $ return = array ( ) ; if ( isset ( $ this -> locale [ 'fmt' ] ) ) { $ address_format_array = explode ( "%" , $ this -> locale [ 'fmt' ] ) ; foreach ( $ address_format_array as $ key => $ value ) { $ value = trim ( $ value ) ; if ( ! empty ( $ value ) && isset ( $ this -> addres... | Return the valid pieces |
6,952 | public function truncator ( $ text , $ number , $ suffix = ' ...see more' ) { if ( ! empty ( $ text ) && intval ( $ number ) ) { if ( strlen ( $ text ) > $ number ) { return mb_substr ( $ text , 0 , mb_strpos ( $ text , ' ' , $ number , 'UTF-8' ) , 'UTF-8' ) . $ suffix ; } return $ text ; } return false ; } | Yo can truncate text and specify number of characters you want to show |
6,953 | public function social ( $ network , $ url ) { if ( ! empty ( $ network ) && ! empty ( $ url ) ) { if ( $ network == 'facebook' ) { $ url_data = sprintf ( $ this -> _facebookUrl , $ url ) ; } switch ( $ network ) { case 'facebook' : $ result = $ this -> _socialCurl ( $ url_data ) ; if ( ! $ result [ $ url ] [ 'share' ]... | This function return number of shares or tweets of the specified page |
6,954 | public function shortenUrl ( $ url , $ provider ) { if ( ! empty ( $ url ) && ! empty ( $ provider ) ) { if ( $ provider == 'tinyurl' ) { $ url_data = sprintf ( $ this -> _tinyUrlShortApiUrl , $ url ) ; } elseif ( $ provider == 'google' ) { $ url_data = sprintf ( '%s/url' , $ this -> _googleShortApiUrl ) ; } switch ( $... | If you want to generate a shorten url simply use this function |
6,955 | public function youtube ( $ url , $ width = 400 , $ height = 250 , $ theme = 'dark' ) { if ( ! empty ( $ url ) && intval ( $ width ) && intval ( $ height ) && ! empty ( $ theme ) ) { preg_match ( '/(?<=v(\=|\/))([-a-zA-Z0-9_]+)|(?<=youtu\.be\/)([-a-zA-Z0-9_]+)/' , $ url , $ v ) ; return "<iframe src=\"https://www.youtu... | This function replaces all youtube link into videos |
6,956 | public function vimeo ( $ url , $ width = 400 , $ height = 250 ) { if ( ! empty ( $ url ) && intval ( $ width ) && intval ( $ height ) ) { preg_match ( '(\d+)' , $ url , $ id ) ; return "<iframe src=\"https://player.vimeo.com/video/$id[0]?title=0&byline=0&portrait=0\" webkitallowfullscreen=\"... | This function replaces all vimeo link into videos |
6,957 | public function encryptString ( $ algo , $ string , $ key = null ) { if ( ! empty ( $ algo ) && ! empty ( $ string ) ) { if ( $ key == null ) { $ ctx = hash_init ( $ algo ) ; } else { $ ctx = hash_init ( $ algo , HASH_HMAC , $ key ) ; hash_update ( $ ctx , $ string ) ; } return hash_final ( $ ctx ) ; } return false ; } | Create an encryption string with a special algorithm and key |
6,958 | public function bbcode ( $ string ) { if ( ! empty ( $ string ) ) { $ search = array ( '@\[(?i)b\](.*?)\[/(?i)b\]@si' , '@\[(?i)i\](.*?)\[/(?i)i\]@si' , '@\[(?i)u\](.*?)\[/(?i)u\]@si' , '@\[(?i)img=(.*?)\](.*?)\[/(?i)img\]@si' , '@\[(?i)youtube\](.*?)\[/(?i)youtube\]@si' , '@\[(?i)vimeo\](.*?)\[/(?i)vimeo\]@si' , '@\[(... | This function converts the following bbcodes into html |
6,959 | public function clean ( $ string ) { if ( ! empty ( $ string ) ) { $ string = preg_replace ( '#<script(.*?)>(.*?)</script>#is' , '' , $ string ) ; $ string = htmlspecialchars ( strip_tags ( $ string , $ this -> _allowableTags ) ) ; $ string = str_replace ( 'href=' , 'rel="nofollow" href=' , $ string ) ; return $ string... | This function clean any text by removing unwanted tags |
6,960 | public function wiki ( $ keyword ) { if ( ! empty ( $ keyword ) ) { $ ch = curl_init ( sprintf ( $ this -> _wikiApiUrl , $ keyword ) ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; $ result = curl_exec ( $ ch ) ; $ error = curl_errno ( $ ch ) ; curl_close ( $ ch ) ; echo $ result ; if ( $ result ) { $ json =... | Get wikipedia definition |
6,961 | public function suggest ( $ keyword ) { if ( ! empty ( $ keyword ) ) { $ ch = curl_init ( sprintf ( $ this -> _googleSuggestApiUrl , $ keyword ) ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , array ( 'Content-Type: text/json' ) ) ; $ result = json_decode ( curl_exec... | Get google suggest for keywords |
6,962 | public function ip ( ) { if ( array_key_exists ( 'HTTP_X_FORWARDED_FOR' , $ _SERVER ) && ! empty ( $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ) ) { if ( strpos ( $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] , ',' ) > 0 ) { $ addr = explode ( "," , $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ) ; return trim ( $ addr [ 0 ] ) ; } else { retur... | This function get real ip address |
6,963 | public function getVideoInfo ( $ url ) { if ( ! empty ( $ url ) ) { if ( strpos ( $ url , 'youtube' ) ) { preg_match ( '/(?<=v(\=|\/))([-a-zA-Z0-9_]+)|(?<=youtu\.be\/)([-a-zA-Z0-9_]+)/' , $ url , $ v ) ; $ provider = 'youtube' ; $ url_data = sprintf ( $ this -> _youtubeVideoApi , $ v [ 0 ] ) ; } elseif ( strpos ( $ url... | Get video info from youtube and vimeo |
6,964 | public function currencyConvert ( $ amount , $ from , $ to ) { if ( $ from === $ to ) { return round ( $ amount , 2 ) ; } if ( $ this -> _currencyConverter === 'currencylayer' ) { return self :: currencyLayerConvert ( $ amount , $ from , $ to ) ; } elseif ( $ this -> _currencyConverter === 'exchangerate' ) { return sel... | This function converts the currency in desired form . |
6,965 | public function smartConvert ( $ amount , $ from , $ to ) { Log :: info ( 'Running Smart Currency Conversion' ) ; if ( $ this -> _currencyLayerApiKey != NULL ) { $ conv = self :: currencyLayerConvert ( $ amount , $ from , $ to ) ; if ( ! $ conv ) { if ( $ this -> _exchangeRateApiKey != NULL ) { return self :: exchangeR... | Smart Currency Conversion This uses the activated APIs and increases your monthly quotas |
6,966 | protected function exchangeRateCalculate ( $ rate , $ amount ) { $ conv = $ amount * $ rate ; $ resque = round ( $ conv , 2 ) ; return $ resque ; } | Calculation of the converted currency |
6,967 | private function _socialCurl ( $ url ) { $ ch = curl_init ( $ url ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , array ( 'Content-Type: text/json' ) ) ; $ result = json_decode ( curl_exec ( $ ch ) , true ) ; curl_close ( $ ch ) ; return $ result ; } | This function used for return tweets and likes with curl |
6,968 | protected function writeCustomConfigFile ( string $ fileName , array $ subjectAltNames ) { $ content = implode ( PHP_EOL , [ '[req]' , 'prompt = no' , 'string_mask = utf8only' , 'distinguished_name = req_distinguished_name' , '[req_distinguished_name]' , '[req_extensions]' , 'subjectAltName = ' . implode ( ',' , $ subj... | The subjectAltName can only be defined in the openssl config . So we need a temporary config file . |
6,969 | private static function read ( $ fd , $ length ) { $ bytes = fread ( $ fd , $ length ) ; if ( false === $ bytes ) { return false ; } return $ bytes ; } | Reads from the stream |
6,970 | public static function readUnsignedVarInt ( $ data ) { $ fd = fopen ( 'data://text/plain,' . urlencode ( $ data ) , 'rb' ) ; $ original = '' ; $ result = $ shift = 0 ; do { $ readValue = self :: read ( $ fd , 1 ) ; if ( false === $ readValue || $ readValue === null ) { return false ; } $ original .= $ readValue ; $ byt... | Read a varint from beginning of the string . |
6,971 | public static function writeUnsignedVarInt ( $ data ) { if ( $ data < 0 ) { throw new InvalidDataException ( 'Cannot write negative values' ) ; } $ orig = $ data ; if ( $ data < 0x80 ) { return new VarInt ( $ data , pack ( 'C' , $ data ) , 1 ) ; } $ encodedBytes = [ ] ; while ( $ data > 0 ) { $ encodedBytes [ ] = 0x80 ... | Writes a VarInt |
6,972 | function fromRawData ( $ data ) { $ versionVarInt = VarInt :: readUnsignedVarInt ( $ data ) ; $ data = substr ( $ data , $ versionVarInt -> getDataLength ( ) ) ; $ addressStringLength = VarInt :: readUnsignedVarInt ( $ data ) ; $ data = substr ( $ data , $ addressStringLength -> getDataLength ( ) ) ; $ address = substr... | Parse the raw data |
6,973 | public function setPkcs12 ( Pkcs12 $ pkcs12 ) { $ this -> setCertificate ( $ pkcs12 -> getCertificate ( ) ) ; $ this -> setPrivateKey ( $ pkcs12 -> getPrivateKey ( ) ) ; } | Set private key and certificate of the certificate authority from PKCS12 . |
6,974 | public function sign ( CertificateSigningRequest $ csr , int $ serial = 0 ) : Certificate { $ certificate = openssl_csr_sign ( $ csr -> export ( ) , $ this -> getCertificate ( ) , $ this -> getPrivateKey ( ) , $ this -> getLifetime ( ) , $ this -> getOptions ( ) , $ serial ) ; return new Certificate ( $ certificate ) ;... | Create a new Certificate . |
6,975 | public function selfSign ( CertificateSigningRequest $ csr , int $ serial = 0 ) : Certificate { $ certificate = openssl_csr_sign ( $ csr -> export ( ) , NULL , $ this -> getPrivateKey ( ) , $ this -> getLifetime ( ) , $ this -> getOptions ( ) , $ serial ) ; return new Certificate ( $ certificate ) ; } | Create a self signed certificate . |
6,976 | public function fetchData ( ) { $ locales = json_decode ( file_get_contents ( $ this -> locale_data_url ) ) ; if ( isset ( $ locales -> countries ) ) { $ countries = explode ( '~' , $ locales -> countries ) ; $ data_dir = __DIR__ . '/i18n' ; foreach ( $ countries as $ country ) { $ file = $ data_dir . '/' . $ country .... | Function to fetch data from Google API and populate local files . |
6,977 | public function onConnection ( AuthClient $ connection ) { $ connection -> on ( 'login_success' , function ( AuthClient $ client , DisconnectPacket $ packet ) { $ this -> emit ( 'login_success' , [ $ client -> getUsername ( ) , $ client -> getUUID ( ) , $ packet ] ) ; } ) ; $ connection -> on ( 'status_request' , funct... | Called on event connection |
6,978 | public function getAuthSource ( $ key ) { if ( ! isset ( $ this -> authSources [ $ key ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'There is no AuthSource called "%s". Available are: %s' , $ key , implode ( ', ' , array_keys ( $ this -> authSources ) ) ) ) ; } return $ this -> container -> get ( $ this -> ... | Get SSPAuthSource . |
6,979 | public function rules ( $ ruleset ) { if ( ! is_array ( $ ruleset ) ) { $ ruleset = [ static :: GLOBAL_KEY => $ ruleset ] ; } foreach ( $ ruleset as $ key => $ rules ) { $ this -> addRule ( $ key , $ rules ) ; } return $ this ; } | Add rules to the sanitizer . |
6,980 | public function sanitize ( $ data ) { if ( $ this -> hasGlobals ( ) ) { if ( ! is_array ( $ data ) ) { return $ this -> sanitizeValueFor ( static :: GLOBAL_KEY , $ data ) ; } foreach ( $ data as $ key => $ value ) { $ data [ $ key ] = $ this -> sanitizeValueFor ( static :: GLOBAL_KEY , $ value ) ; } } foreach ( $ data ... | Sanitize some data . |
6,981 | protected function sanitizeValueFor ( $ key , $ value ) { foreach ( $ this -> rules [ $ key ] as $ rule ) { $ value = call_user_func_array ( $ this -> getCallable ( $ rule [ 0 ] , $ key ) , $ this -> buildArguments ( $ value , isset ( $ rule [ 1 ] ) ? $ rule [ 1 ] : null ) ) ; } return $ value ; } | Sanitize a single value for a given key . |
6,982 | protected function getCallable ( $ value , $ key ) { if ( is_string ( $ value ) && $ this -> hasRegistrar ( ) && $ this -> registrar -> isRegistred ( $ value ) ) { $ value = $ this -> registrar -> resolve ( $ value ) ; } if ( is_callable ( $ value ) ) { return $ value ; } if ( is_object ( $ value ) && method_exists ( $... | Resolve the callable for a given rule . |
6,983 | protected function buildArguments ( $ value , array $ args = null ) { if ( ! $ args ) { return ( array ) $ value ; } $ valuePosition = array_search ( static :: PLACEHOLDER_VALUE , $ args , true ) ; if ( $ valuePosition === false ) { return array_merge ( ( array ) $ value , $ args ) ; } else { $ args [ $ valuePosition ]... | Build the arguments for a callback . |
6,984 | protected function addRule ( $ key , $ rules ) { if ( $ this -> shouldSanitize ( $ key ) ) { throw new InvalidArgumentException ( sprintf ( 'Sanitation rules are already defined for field [%s]' , $ key ) ) ; } $ this -> rules [ $ key ] = $ this -> buildRules ( $ rules ) ; } | Add a rule to the sanitizer factory . |
6,985 | protected function buildRules ( $ rules ) { if ( is_string ( $ rules ) ) { $ rules = explode ( '|' , $ rules ) ; } elseif ( is_object ( $ rules ) ) { $ rules = [ $ rules ] ; } $ built = [ ] ; foreach ( ( array ) $ rules as $ rule ) { if ( is_string ( $ rule ) && strpos ( $ rule , ':' ) !== false ) { $ args = explode ( ... | Build a valid set of rules . |
6,986 | public static function getStrongPseudoRandomBytes ( int $ length ) : string { $ result = openssl_random_pseudo_bytes ( $ length , $ strong ) ; if ( ! $ strong ) { throw new RuntimeException ( 'Not strong enough' ) ; } return $ result ; } | Get strong random bytes . |
6,987 | public function export ( bool $ verbose = false ) : string { openssl_csr_export ( $ this -> getHandle ( ) , $ output , ! $ verbose ) ; return $ output ; } | Export as string . |
6,988 | public function exportToFile ( string $ fileName , bool $ verbose = false ) { openssl_csr_export_to_file ( $ this -> getHandle ( ) , $ fileName , ! $ verbose ) ; } | Export to a file . |
6,989 | public function getPaginated ( $ paged = 15 , $ orderBy = 'created_at' , $ sort = 'desc' ) { $ query = function ( ) use ( $ paged , $ orderBy , $ sort ) { return $ this -> model -> with ( $ this -> requiredRelationships ) -> orderBy ( $ orderBy , $ sort ) -> paginate ( $ paged ) ; } ; return $ this -> doQuery ( $ query... | Get paged items |
6,990 | public function getForSelect ( $ data , $ key = 'id' , $ orderBy = 'created_at' , $ sort = 'desc' ) { $ query = function ( ) use ( $ data , $ key , $ orderBy , $ sort ) { return $ this -> model -> with ( $ this -> requiredRelationships ) -> orderBy ( $ orderBy , $ sort ) -> lists ( $ data , $ key ) -> all ( ) ; } ; ret... | Items for select options |
6,991 | public function getById ( $ id ) { $ query = function ( ) use ( $ id ) { return $ this -> model -> with ( $ this -> requiredRelationships ) -> find ( $ id ) ; } ; return $ this -> doQuery ( $ query ) ; } | Get item by its id |
6,992 | public function getActively ( $ term , $ column = 'slug' ) { if ( is_numeric ( $ term ) ) { return $ this -> getById ( $ term ) ; } return $ this -> getItemByColumn ( $ term , $ column ) ; } | Get item by id or column |
6,993 | public function update ( $ id , array $ data ) { return $ this -> model -> where ( $ this -> model -> getKeyName ( ) , $ id ) -> update ( $ data ) ; } | Update a record using the primary key . |
6,994 | public function updateOrCreate ( array $ identifiers , array $ data ) { $ existing = $ this -> model -> where ( array_only ( $ data , $ identifiers ) ) -> first ( ) ; if ( $ existing ) { $ existing -> update ( $ data ) ; return $ existing ; } return $ this -> create ( $ data ) ; } | Update or crate a record and return the entity |
6,995 | public function delete ( $ id ) { return $ this -> model -> where ( $ this -> model -> getKeyName ( ) , $ id ) -> delete ( ) ; } | Delete a record by the primary key . |
6,996 | public function with ( $ relationships ) { $ this -> requiredRelationships = [ ] ; if ( $ relationships == 'all' ) { $ this -> requiredRelationships = $ this -> relationships ; } elseif ( is_array ( $ relationships ) ) { $ this -> requiredRelationships = array_filter ( $ relationships , function ( $ value ) { return in... | Choose what relationships to return with query . |
6,997 | protected function doQuery ( $ callback ) { $ previousMethod = debug_backtrace ( null , 2 ) [ 1 ] ; $ methodName = $ previousMethod [ 'function' ] ; $ arguments = $ previousMethod [ 'args' ] ; $ result = $ this -> doBeforeQuery ( $ callback , $ methodName , $ arguments ) ; return $ this -> doAfterQuery ( $ result , $ m... | Perform the repository query . |
6,998 | private function doBeforeQuery ( $ callback , $ methodName , $ arguments ) { $ traits = $ this -> getUsedTraits ( ) ; if ( in_array ( CacheResults :: class , $ traits ) && $ this -> caching && $ this -> isCacheableMethod ( $ methodName ) ) { return $ this -> processCacheRequest ( $ callback , $ methodName , $ arguments... | Apply any modifiers to the query . |
6,999 | private function doAfterQuery ( $ result , $ methodName , $ arguments ) { $ traits = $ this -> getUsedTraits ( ) ; if ( in_array ( CacheResults :: class , $ traits ) ) { $ this -> caching = true ; } if ( in_array ( ThrowsHttpExceptions :: class , $ traits ) ) { if ( $ this -> shouldThrowHttpException ( $ result , $ met... | Handle the query result . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.