idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
50,700 | public function intVal ( ) : int { if ( ! isset ( $ this -> _intNum ) ) { $ num = gmp_init ( $ this -> _num , 10 ) ; if ( gmp_cmp ( $ num , $ this -> _intMaxGmp ( ) ) > 0 ) { throw new \ RuntimeException ( "Integer overflow." ) ; } if ( gmp_cmp ( $ num , $ this -> _intMinGmp ( ) ) < 0 ) { throw new \ RuntimeException ( "Integer underflow." ) ; } $ this -> _intNum = gmp_intval ( $ num ) ; } return $ this -> _intNum ; } | Get the number as an integer . |
50,701 | public function sendPersonalized ( $ messages , $ sender = null , $ params = array ( ) ) { $ params = array_merge ( array ( 'messages' => $ messages , 'sender' => $ sender ) , $ params ) ; return $ this -> master -> call ( 'messages/send_personalized' , $ params ) ; } | Sending personalized messages |
50,702 | public function sendVoice ( $ phone , $ params = array ( ) ) { $ params = array_merge ( array ( 'phone' => $ phone ) , $ params ) ; return $ this -> master -> call ( 'messages/send_voice' , $ params ) ; } | Sending Voice message |
50,703 | public function view ( $ id , $ params = array ( ) ) { $ params = array_merge ( array ( 'id' => $ id ) , $ params ) ; return $ this -> master -> call ( 'messages/view' , $ params ) ; } | View single message |
50,704 | public function delete ( $ id , $ unique_id = null ) { $ params = array ( 'id' => $ id , 'unique_id' => $ unique_id ) ; return $ this -> master -> call ( 'messages/delete' , $ params ) ; } | Deleting message from the scheduler |
50,705 | public function recived ( $ type , $ params = array ( ) ) { $ params = array_merge ( array ( 'type' => $ type ) , $ params ) ; return $ this -> master -> call ( 'messages/recived' , $ params ) ; } | List of received messages |
50,706 | public function getData ( ) { $ this -> validate ( 'amount' , 'token' ) ; $ data = array ( ) ; $ data [ 'token' ] = $ this -> getToken ( ) ; $ data [ 'amount' ] = $ this -> getAmountInteger ( ) ; $ data [ 'currencyCode' ] = $ this -> getCurrency ( ) ; $ data [ 'orderDescription' ] = $ this -> getDescription ( ) ; $ data [ 'customerOrderCode' ] = $ this -> getTransactionId ( ) ; $ data [ 'currency' ] = $ this -> getCurrency ( ) ; $ card = $ this -> getCard ( ) ; if ( $ card ) { $ data [ 'billingAddress' ] = array ( ) ; $ data [ 'billingAddress' ] [ 'address1' ] = $ card -> getBillingAddress1 ( ) ; $ data [ 'billingAddress' ] [ 'address2' ] = $ card -> getBillingAddress2 ( ) ; $ data [ 'billingAddress' ] [ 'city' ] = $ card -> getBillingCity ( ) ; $ data [ 'billingAddress' ] [ 'state' ] = $ card -> getBillingState ( ) ; $ data [ 'billingAddress' ] [ 'countryCode' ] = $ card -> getBillingCountry ( ) ; $ data [ 'billingAddress' ] [ 'postalCode' ] = $ card -> getBillingPostcode ( ) ; $ data [ 'billingAddress' ] [ 'telephoneNumber' ] = $ card -> getBillingPhone ( ) ; $ data [ 'name' ] = $ card -> getName ( ) ; $ data [ 'deliveryAddress' ] = array ( ) ; $ data [ 'deliveryAddress' ] [ 'firstName' ] = $ card -> getShippingFirstName ( ) ; $ data [ 'deliveryAddress' ] [ 'lastName' ] = $ card -> getShippingLastName ( ) ; $ data [ 'deliveryAddress' ] [ 'address1' ] = $ card -> getShippingAddress1 ( ) ; $ data [ 'deliveryAddress' ] [ 'address2' ] = $ card -> getShippingAddress2 ( ) ; $ data [ 'deliveryAddress' ] [ 'city' ] = $ card -> getShippingCity ( ) ; $ data [ 'deliveryAddress' ] [ 'state' ] = $ card -> getShippingState ( ) ; $ data [ 'deliveryAddress' ] [ 'countryCode' ] = $ card -> getShippingCountry ( ) ; $ data [ 'deliveryAddress' ] [ 'postalCode' ] = $ card -> getShippingPostcode ( ) ; $ data [ 'deliveryAddress' ] [ 'telephoneNumber' ] = $ card -> getBillingPhone ( ) ; $ data [ 'shopperEmailAddress' ] = $ card -> getEmail ( ) ; } $ data [ 'shopperIpAddress' ] = $ this -> getClientIp ( ) ; $ data [ 'orderType' ] = 'ECOM' ; return $ data ; } | Set up the base data for a purchase request |
50,707 | public function index ( $ phone = null , $ params = array ( ) ) { $ params = array_merge ( array ( 'phone' => $ phone ) , $ params ) ; return $ this -> master -> call ( 'blacklist/index' , $ params ) ; } | List of blacklist phones |
50,708 | private function getFileName ( ) { $ name = $ this -> getArgumentNameOnly ( ) ; switch ( $ this -> option ( 'type' ) ) { case 'view' : break ; case 'model' : $ name = $ this -> getModelName ( ) ; break ; case 'controller' : $ name = $ this -> getControllerName ( $ name ) ; break ; case 'seed' : $ name = $ this -> getSeedName ( $ name ) ; break ; } if ( $ this -> option ( 'name' ) ) { return $ this -> option ( 'name' ) . $ this -> settings [ 'file_type' ] ; } return $ this -> settings [ 'prefix' ] . $ name . $ this -> settings [ 'postfix' ] . $ this -> settings [ 'file_type' ] ; } | Get the filename of the file to generate |
50,709 | protected function getUrl ( $ lowercase = true ) { if ( $ lowercase ) { $ url = '/' . rtrim ( implode ( '/' , array_map ( 'snake_case' , explode ( '/' , $ this -> getArgumentPath ( true ) ) ) ) , '/' ) ; $ url = ( implode ( '/' , array_map ( 'str_slug' , explode ( '/' , $ url ) ) ) ) ; return $ url ; } return '/' . rtrim ( implode ( '/' , explode ( '/' , $ this -> getArgumentPath ( true ) ) ) , '/' ) ; } | Get the url for the given name |
50,710 | public function loadXpathFromDoc ( \ DOMDocument $ doc ) { $ docName = $ doc -> documentElement -> localName ; $ this -> root = '/' . self :: ROOT_PREFIX . ':' . $ docName ; $ this -> xpath = new \ DOMXPath ( $ doc ) ; $ this -> xpath -> registerNamespace ( self :: ROOT_PREFIX , $ doc -> documentElement -> namespaceURI ) ; } | Init XPath from document . |
50,711 | private function callView ( ) { if ( $ this -> confirm ( "Create crud views for the $this->resource resource?" ) ) { $ views = config ( 'generators.resource_views' ) ; foreach ( $ views as $ key => $ name ) { $ resource = $ this -> argument ( 'resource' ) ; if ( str_contains ( $ resource , '.' ) ) { $ resource = str_replace ( '.' , '/' , $ resource ) ; } $ this -> callCommandFile ( 'view' , $ this -> getViewPath ( $ resource ) , $ key , [ '--name' => $ name ] ) ; } } } | Generate the resource views |
50,712 | private function callController ( ) { $ name = $ this -> getResourceControllerName ( ) ; if ( $ this -> confirm ( "Create a controller ($name) for the $this->resource resource?" ) ) { $ arg = $ this -> getArgumentResource ( ) ; $ name = substr_replace ( $ arg , str_plural ( $ this -> resource ) , strrpos ( $ arg , $ this -> resource ) , strlen ( $ this -> resource ) ) ; if ( $ this -> repositoryContract ) { $ this -> callCommandFile ( 'controller' , $ name , 'controller_repository' ) ; } else { if ( ! str_contains ( $ name , 'admin.' ) ) { $ this -> callCommandFile ( 'controller' , $ name , 'controller' ) ; } else { $ this -> callCommandFile ( 'controller' , $ name , 'controller_admin' ) ; } } } } | Generate the resource controller |
50,713 | private function getArgumentResource ( ) { $ name = $ this -> argument ( 'resource' ) ; if ( str_contains ( $ name , '/' ) ) { $ name = str_replace ( '/' , '.' , $ name ) ; } if ( str_contains ( $ name , '\\' ) ) { $ name = str_replace ( '\\' , '.' , $ name ) ; } $ name = strtolower ( str_singular ( $ name ) ) ; return $ name ; } | The resource argument Lowercase and singular each word |
50,714 | private function getResourceOnly ( ) { $ name = $ this -> getArgumentResource ( ) ; if ( ! str_contains ( $ name , '.' ) ) { return $ name ; } return substr ( $ name , strripos ( $ name , '.' ) + 1 ) ; } | If there are . in the name get the last occurence |
50,715 | protected function getErrorFromFault ( \ SoapFault $ fault ) { $ error = $ this -> getErrorByCode ( $ fault -> faultcode , $ fault -> faultstring ) ; if ( empty ( $ error -> getMessage ( ) ) ) { $ error -> setMessage ( isset ( $ fault -> detail ) ? $ fault -> detail -> message : $ fault -> faultstring ) ; } return $ error ; } | Get error from Fault Exception . |
50,716 | public function range ( int $ start , int $ length ) : string { if ( ! $ length ) { return "0" ; } if ( $ start + $ length > $ this -> numBits ( ) ) { throw new \ OutOfBoundsException ( "Not enough bits." ) ; } $ bits = gmp_init ( 0 ) ; $ idx = $ start ; $ end = $ start + $ length ; while ( true ) { $ bit = $ this -> testBit ( $ idx ) ? 1 : 0 ; $ bits |= $ bit ; if ( ++ $ idx >= $ end ) { break ; } $ bits <<= 1 ; } return gmp_strval ( $ bits , 10 ) ; } | Get range of bits . |
50,717 | public function withoutTrailingZeroes ( ) : self { if ( ! strlen ( $ this -> _string ) ) { return new self ( "" ) ; } $ bits = $ this -> _string ; $ unused_octets = 0 ; for ( $ idx = strlen ( $ bits ) - 1 ; $ idx >= 0 ; -- $ idx , ++ $ unused_octets ) { if ( $ bits [ $ idx ] != "\x0" ) { break ; } } if ( $ unused_octets ) { $ bits = substr ( $ bits , 0 , - $ unused_octets ) ; } if ( ! strlen ( $ bits ) ) { return new self ( "" ) ; } $ unused_bits = 0 ; $ byte = ord ( $ bits [ strlen ( $ bits ) - 1 ] ) ; while ( ! ( $ byte & 0x01 ) ) { $ unused_bits ++ ; $ byte >>= 1 ; } return new self ( $ bits , $ unused_bits ) ; } | Get a copy of the bit string with trailing zeroes removed . |
50,718 | private static function _decodeDefiniteLength ( string $ data , int & $ offset , int $ length ) : ElementBase { $ idx = $ offset ; $ end = $ idx + $ length ; $ elements = [ ] ; while ( $ idx < $ end ) { $ elements [ ] = Element :: fromDER ( $ data , $ idx ) ; if ( $ idx > $ end ) { throw new DecodeException ( "Structure's content overflows length." ) ; } } $ offset = $ idx ; return new static ( ... $ elements ) ; } | Decode elements for a definite length . |
50,719 | private static function _decodeIndefiniteLength ( string $ data , int & $ offset ) : ElementBase { $ idx = $ offset ; $ elements = [ ] ; $ end = strlen ( $ data ) ; while ( true ) { if ( $ idx >= $ end ) { throw new DecodeException ( 'Unexpected end of data while decoding indefinite length structure.' ) ; } $ el = Element :: fromDER ( $ data , $ idx ) ; if ( $ el -> isType ( self :: TYPE_EOC ) ) { break ; } $ elements [ ] = $ el ; } $ offset = $ idx ; $ type = new static ( ... $ elements ) ; $ type -> _indefiniteLength = true ; return $ type ; } | Decode elements for an indefinite length . |
50,720 | public static function explodeDER ( string $ data ) : array { $ offset = 0 ; $ identifier = Identifier :: fromDER ( $ data , $ offset ) ; if ( ! $ identifier -> isConstructed ( ) ) { throw new DecodeException ( "Element is not constructed." ) ; } $ length = Length :: expectFromDER ( $ data , $ offset ) ; if ( $ length -> isIndefinite ( ) ) { throw new DecodeException ( 'Explode not implemented for indefinite length encoding.' ) ; } $ end = $ offset + $ length -> intLength ( ) ; $ parts = [ ] ; while ( $ offset < $ end ) { $ idx = $ offset ; Identifier :: fromDER ( $ data , $ offset ) ; $ length = Length :: expectFromDER ( $ data , $ offset ) -> intLength ( ) ; $ parts [ ] = substr ( $ data , $ idx , $ offset - $ idx + $ length ) ; $ offset += $ length ; } return $ parts ; } | Explode DER structure to DER encoded components that it contains . |
50,721 | public function withReplaced ( int $ idx , Element $ el ) : self { if ( ! isset ( $ this -> _elements [ $ idx ] ) ) { throw new \ OutOfBoundsException ( "Structure doesn't have element at index $idx." ) ; } $ obj = clone $ this ; $ obj -> _elements [ $ idx ] = $ el ; return $ obj ; } | Get self with an element at the given index replaced by another . |
50,722 | public function withInserted ( int $ idx , Element $ el ) : self { if ( count ( $ this -> _elements ) < $ idx || $ idx < 0 ) { throw new \ OutOfBoundsException ( "Index $idx is out of bounds." ) ; } $ obj = clone $ this ; array_splice ( $ obj -> _elements , $ idx , 0 , [ $ el ] ) ; return $ obj ; } | Get self with an element inserted before the given index . |
50,723 | public function withAppended ( Element $ el ) : self { $ obj = clone $ this ; array_push ( $ obj -> _elements , $ el ) ; return $ obj ; } | Get self with an element appended to the end . |
50,724 | public function withPrepended ( Element $ el ) : self { $ obj = clone $ this ; array_unshift ( $ obj -> _elements , $ el ) ; return $ obj ; } | Get self with an element prepended in the beginning . |
50,725 | public function withoutElement ( int $ idx ) : self { if ( ! isset ( $ this -> _elements [ $ idx ] ) ) { throw new \ OutOfBoundsException ( "Structure doesn't have element at index $idx." ) ; } $ obj = clone $ this ; array_splice ( $ obj -> _elements , $ idx , 1 ) ; return $ obj ; } | Get self with an element at the given index removed . |
50,726 | public function elements ( ) : array { if ( ! isset ( $ this -> _unspecifiedTypes ) ) { $ this -> _unspecifiedTypes = array_map ( function ( Element $ el ) { return new UnspecifiedType ( $ el ) ; } , $ this -> _elements ) ; } return $ this -> _unspecifiedTypes ; } | Get elements in the structure . |
50,727 | public function has ( int $ idx , $ expectedTag = null ) : bool { if ( ! isset ( $ this -> _elements [ $ idx ] ) ) { return false ; } if ( isset ( $ expectedTag ) ) { if ( ! $ this -> _elements [ $ idx ] -> isType ( $ expectedTag ) ) { return false ; } } return true ; } | Check whether the structure has an element at the given index optionally satisfying given tag expectation . |
50,728 | public function at ( int $ idx , $ expectedTag = null ) : UnspecifiedType { if ( ! isset ( $ this -> _elements [ $ idx ] ) ) { throw new \ OutOfBoundsException ( "Structure doesn't have an element at index $idx." ) ; } $ element = $ this -> _elements [ $ idx ] ; if ( isset ( $ expectedTag ) ) { $ element -> expectType ( $ expectedTag ) ; } return new UnspecifiedType ( $ element ) ; } | Get the element at the given index optionally checking that the element has a given tag . |
50,729 | public function hasTagged ( int $ tag ) : bool { if ( ! isset ( $ this -> _taggedMap ) ) { $ this -> _taggedMap = [ ] ; foreach ( $ this -> _elements as $ element ) { if ( $ element -> isTagged ( ) ) { $ this -> _taggedMap [ $ element -> tag ( ) ] = $ element ; } } } return isset ( $ this -> _taggedMap [ $ tag ] ) ; } | Check whether the structure contains a context specific element with a given tag . |
50,730 | public function getTagged ( int $ tag ) : TaggedType { if ( ! $ this -> hasTagged ( $ tag ) ) { throw new \ LogicException ( "No tagged element for tag $tag." ) ; } return $ this -> _taggedMap [ $ tag ] ; } | Get a context specific element tagged with a given tag . |
50,731 | protected function getModelName ( $ name = null ) { $ name = str_singular ( $ this -> meta [ 'table' ] ) ; $ model = '' ; $ pieces = explode ( '_' , $ name ) ; foreach ( $ pieces as $ k => $ str ) { $ model = $ model . ucwords ( $ str ) ; } return $ model ; } | Get the class name for the Eloquent model generator . |
50,732 | public static function fromElementBase ( ElementBase $ el ) : self { if ( $ el instanceof self ) { return $ el ; } return new self ( $ el -> asElement ( ) ) ; } | Initialize from ElementBase interface . |
50,733 | public function asTagged ( ) : TaggedType { if ( ! $ this -> _element instanceof TaggedType ) { throw new \ UnexpectedValueException ( "Tagged element expected, got " . $ this -> _typeDescriptorString ( ) ) ; } return $ this -> _element ; } | Get the wrapped element as a context specific tagged type . |
50,734 | public function asApplication ( ) : Tagged \ ApplicationType { if ( ! $ this -> _element instanceof Tagged \ ApplicationType ) { throw new \ UnexpectedValueException ( "Application type expected, got " . $ this -> _typeDescriptorString ( ) ) ; } return $ this -> _element ; } | Get the wrapped element as an application specific type . |
50,735 | public function asPrivate ( ) : Tagged \ PrivateType { if ( ! $ this -> _element instanceof Tagged \ PrivateType ) { throw new \ UnexpectedValueException ( "Private type expected, got " . $ this -> _typeDescriptorString ( ) ) ; } return $ this -> _element ; } | Get the wrapped element as a private tagged type . |
50,736 | public function asBoolean ( ) : Primitive \ Boolean { if ( ! $ this -> _element instanceof Primitive \ Boolean ) { throw new \ UnexpectedValueException ( $ this -> _generateExceptionMessage ( Element :: TYPE_BOOLEAN ) ) ; } return $ this -> _element ; } | Get the wrapped element as a boolean type . |
50,737 | public function asInteger ( ) : Primitive \ Integer { if ( ! $ this -> _element instanceof Primitive \ Integer ) { throw new \ UnexpectedValueException ( $ this -> _generateExceptionMessage ( Element :: TYPE_INTEGER ) ) ; } return $ this -> _element ; } | Get the wrapped element as an integer type . |
50,738 | public function asBitString ( ) : Primitive \ BitString { if ( ! $ this -> _element instanceof Primitive \ BitString ) { throw new \ UnexpectedValueException ( $ this -> _generateExceptionMessage ( Element :: TYPE_BIT_STRING ) ) ; } return $ this -> _element ; } | Get the wrapped element as a bit string type . |
50,739 | public function asOctetString ( ) : Primitive \ OctetString { if ( ! $ this -> _element instanceof Primitive \ OctetString ) { throw new \ UnexpectedValueException ( $ this -> _generateExceptionMessage ( Element :: TYPE_OCTET_STRING ) ) ; } return $ this -> _element ; } | Get the wrapped element as an octet string type . |
50,740 | public function asNull ( ) : Primitive \ NullType { if ( ! $ this -> _element instanceof Primitive \ NullType ) { throw new \ UnexpectedValueException ( $ this -> _generateExceptionMessage ( Element :: TYPE_NULL ) ) ; } return $ this -> _element ; } | Get the wrapped element as a null type . |
50,741 | public function asObjectIdentifier ( ) : Primitive \ ObjectIdentifier { if ( ! $ this -> _element instanceof Primitive \ ObjectIdentifier ) { throw new \ UnexpectedValueException ( $ this -> _generateExceptionMessage ( Element :: TYPE_OBJECT_IDENTIFIER ) ) ; } return $ this -> _element ; } | Get the wrapped element as an object identifier type . |
50,742 | public function asObjectDescriptor ( ) : Primitive \ ObjectDescriptor { if ( ! $ this -> _element instanceof Primitive \ ObjectDescriptor ) { throw new \ UnexpectedValueException ( $ this -> _generateExceptionMessage ( Element :: TYPE_OBJECT_DESCRIPTOR ) ) ; } return $ this -> _element ; } | Get the wrapped element as an object descriptor type . |
50,743 | public function asReal ( ) : Primitive \ Real { if ( ! $ this -> _element instanceof Primitive \ Real ) { throw new \ UnexpectedValueException ( $ this -> _generateExceptionMessage ( Element :: TYPE_REAL ) ) ; } return $ this -> _element ; } | Get the wrapped element as a real type . |
50,744 | public function asEnumerated ( ) : Primitive \ Enumerated { if ( ! $ this -> _element instanceof Primitive \ Enumerated ) { throw new \ UnexpectedValueException ( $ this -> _generateExceptionMessage ( Element :: TYPE_ENUMERATED ) ) ; } return $ this -> _element ; } | Get the wrapped element as an enumerated type . |
50,745 | public function asUTF8String ( ) : Primitive \ UTF8String { if ( ! $ this -> _element instanceof Primitive \ UTF8String ) { throw new \ UnexpectedValueException ( $ this -> _generateExceptionMessage ( Element :: TYPE_UTF8_STRING ) ) ; } return $ this -> _element ; } | Get the wrapped element as a UTF8 string type . |
50,746 | public function asRelativeOID ( ) : Primitive \ RelativeOID { if ( ! $ this -> _element instanceof Primitive \ RelativeOID ) { throw new \ UnexpectedValueException ( $ this -> _generateExceptionMessage ( Element :: TYPE_RELATIVE_OID ) ) ; } return $ this -> _element ; } | Get the wrapped element as a relative OID type . |
50,747 | public function asSequence ( ) : Constructed \ Sequence { if ( ! $ this -> _element instanceof Constructed \ Sequence ) { throw new \ UnexpectedValueException ( $ this -> _generateExceptionMessage ( Element :: TYPE_SEQUENCE ) ) ; } return $ this -> _element ; } | Get the wrapped element as a sequence type . |
50,748 | public function asSet ( ) : Constructed \ Set { if ( ! $ this -> _element instanceof Constructed \ Set ) { throw new \ UnexpectedValueException ( $ this -> _generateExceptionMessage ( Element :: TYPE_SET ) ) ; } return $ this -> _element ; } | Get the wrapped element as a set type . |
50,749 | public function asNumericString ( ) : Primitive \ NumericString { if ( ! $ this -> _element instanceof Primitive \ NumericString ) { throw new \ UnexpectedValueException ( $ this -> _generateExceptionMessage ( Element :: TYPE_NUMERIC_STRING ) ) ; } return $ this -> _element ; } | Get the wrapped element as a numeric string type . |
50,750 | public function asPrintableString ( ) : Primitive \ PrintableString { if ( ! $ this -> _element instanceof Primitive \ PrintableString ) { throw new \ UnexpectedValueException ( $ this -> _generateExceptionMessage ( Element :: TYPE_PRINTABLE_STRING ) ) ; } return $ this -> _element ; } | Get the wrapped element as a printable string type . |
50,751 | public function asT61String ( ) : Primitive \ T61String { if ( ! $ this -> _element instanceof Primitive \ T61String ) { throw new \ UnexpectedValueException ( $ this -> _generateExceptionMessage ( Element :: TYPE_T61_STRING ) ) ; } return $ this -> _element ; } | Get the wrapped element as a T61 string type . |
50,752 | public function asVideotexString ( ) : Primitive \ VideotexString { if ( ! $ this -> _element instanceof Primitive \ VideotexString ) { throw new \ UnexpectedValueException ( $ this -> _generateExceptionMessage ( Element :: TYPE_VIDEOTEX_STRING ) ) ; } return $ this -> _element ; } | Get the wrapped element as a videotex string type . |
50,753 | public function asIA5String ( ) : Primitive \ IA5String { if ( ! $ this -> _element instanceof Primitive \ IA5String ) { throw new \ UnexpectedValueException ( $ this -> _generateExceptionMessage ( Element :: TYPE_IA5_STRING ) ) ; } return $ this -> _element ; } | Get the wrapped element as a IA5 string type . |
50,754 | public function asUTCTime ( ) : Primitive \ UTCTime { if ( ! $ this -> _element instanceof Primitive \ UTCTime ) { throw new \ UnexpectedValueException ( $ this -> _generateExceptionMessage ( Element :: TYPE_UTC_TIME ) ) ; } return $ this -> _element ; } | Get the wrapped element as an UTC time type . |
50,755 | public function asGeneralizedTime ( ) : Primitive \ GeneralizedTime { if ( ! $ this -> _element instanceof Primitive \ GeneralizedTime ) { throw new \ UnexpectedValueException ( $ this -> _generateExceptionMessage ( Element :: TYPE_GENERALIZED_TIME ) ) ; } return $ this -> _element ; } | Get the wrapped element as a generalized time type . |
50,756 | public function asGraphicString ( ) : Primitive \ GraphicString { if ( ! $ this -> _element instanceof Primitive \ GraphicString ) { throw new \ UnexpectedValueException ( $ this -> _generateExceptionMessage ( Element :: TYPE_GRAPHIC_STRING ) ) ; } return $ this -> _element ; } | Get the wrapped element as a graphic string type . |
50,757 | public function asVisibleString ( ) : Primitive \ VisibleString { if ( ! $ this -> _element instanceof Primitive \ VisibleString ) { throw new \ UnexpectedValueException ( $ this -> _generateExceptionMessage ( Element :: TYPE_VISIBLE_STRING ) ) ; } return $ this -> _element ; } | Get the wrapped element as a visible string type . |
50,758 | public function asGeneralString ( ) : Primitive \ GeneralString { if ( ! $ this -> _element instanceof Primitive \ GeneralString ) { throw new \ UnexpectedValueException ( $ this -> _generateExceptionMessage ( Element :: TYPE_GENERAL_STRING ) ) ; } return $ this -> _element ; } | Get the wrapped element as a general string type . |
50,759 | public function asUniversalString ( ) : Primitive \ UniversalString { if ( ! $ this -> _element instanceof Primitive \ UniversalString ) { throw new \ UnexpectedValueException ( $ this -> _generateExceptionMessage ( Element :: TYPE_UNIVERSAL_STRING ) ) ; } return $ this -> _element ; } | Get the wrapped element as a universal string type . |
50,760 | public function asCharacterString ( ) : Primitive \ CharacterString { if ( ! $ this -> _element instanceof Primitive \ CharacterString ) { throw new \ UnexpectedValueException ( $ this -> _generateExceptionMessage ( Element :: TYPE_CHARACTER_STRING ) ) ; } return $ this -> _element ; } | Get the wrapped element as a character string type . |
50,761 | public function asBMPString ( ) : Primitive \ BMPString { if ( ! $ this -> _element instanceof Primitive \ BMPString ) { throw new \ UnexpectedValueException ( $ this -> _generateExceptionMessage ( Element :: TYPE_BMP_STRING ) ) ; } return $ this -> _element ; } | Get the wrapped element as a BMP string type . |
50,762 | public function asString ( ) : StringType { if ( ! $ this -> _element instanceof StringType ) { throw new \ UnexpectedValueException ( $ this -> _generateExceptionMessage ( Element :: TYPE_STRING ) ) ; } return $ this -> _element ; } | Get the wrapped element as any string type . |
50,763 | public function asTime ( ) : TimeType { if ( ! $ this -> _element instanceof TimeType ) { throw new \ UnexpectedValueException ( $ this -> _generateExceptionMessage ( Element :: TYPE_TIME ) ) ; } return $ this -> _element ; } | Get the wrapped element as any time type . |
50,764 | private function _typeDescriptorString ( ) : string { $ type_cls = $ this -> _element -> typeClass ( ) ; $ tag = $ this -> _element -> tag ( ) ; if ( $ type_cls == Identifier :: CLASS_UNIVERSAL ) { return Element :: tagToName ( $ tag ) ; } return Identifier :: classToName ( $ type_cls ) . " TAG $tag" ; } | Get textual description of the wrapped element for debugging purposes . |
50,765 | private static function _encodePositiveInteger ( \ GMP $ num ) : string { $ bin = gmp_export ( $ num , 1 , GMP_MSW_FIRST | GMP_BIG_ENDIAN ) ; if ( ord ( $ bin [ 0 ] ) & 0x80 ) { $ bin = chr ( 0x00 ) . $ bin ; } return $ bin ; } | Encode positive integer to DER content . |
50,766 | private static function _encodeNegativeInteger ( \ GMP $ num ) : string { $ num = gmp_abs ( $ num ) ; $ width = 1 ; if ( $ num > 128 ) { $ tmp = $ num ; do { $ width ++ ; $ tmp >>= 8 ; } while ( $ tmp > 128 ) ; } $ num = gmp_pow ( "2" , 8 * $ width ) - $ num ; $ bin = gmp_export ( $ num , 1 , GMP_MSW_FIRST | GMP_BIG_ENDIAN ) ; if ( ! ( ord ( $ bin [ 0 ] ) & 0x80 ) ) { $ bin = chr ( 0xff ) . $ bin ; } return $ bin ; } | Encode negative integer to DER content . |
50,767 | private static function _validateNumber ( $ num ) : bool { if ( is_int ( $ num ) ) { return true ; } if ( is_string ( $ num ) && preg_match ( '/-?\d+/' , $ num ) ) { return true ; } return false ; } | Test that number is valid for this context . |
50,768 | public function add ( $ subaccount_username , $ subaccount_password , $ subaccount_id , $ params = array ( ) ) { $ params = array_merge ( array ( 'subaccount_username' => $ subaccount_username , 'subaccount_password' => $ subaccount_password , 'subaccount_id' => $ subaccount_id ) , $ params ) ; return $ this -> master -> call ( 'subaccounts/add' , $ params ) ; } | Creating new subaccount |
50,769 | public function limit ( $ id , $ type , $ value ) { $ params = array ( 'id' => $ id , 'type' => $ type , 'value' => $ value ) ; return $ this -> master -> call ( 'subaccounts/limit' , $ params ) ; } | Setting the limit on subaccount |
50,770 | public static function fromDER ( string $ data , int & $ offset = null ) : Identifier { $ idx = $ offset ?? 0 ; $ datalen = strlen ( $ data ) ; if ( $ idx >= $ datalen ) { throw new DecodeException ( "Invalid offset." ) ; } $ byte = ord ( $ data [ $ idx ++ ] ) ; $ class = ( 0b11000000 & $ byte ) >> 6 ; $ pc = ( 0b00100000 & $ byte ) >> 5 ; $ tag = ( 0b00011111 & $ byte ) ; if ( 0x1f == $ tag ) { $ tag = self :: _decodeLongFormTag ( $ data , $ idx ) ; } if ( isset ( $ offset ) ) { $ offset = $ idx ; } return new self ( $ class , $ pc , $ tag ) ; } | Decode identifier component from DER data . |
50,771 | private static function _decodeLongFormTag ( string $ data , int & $ offset ) : string { $ datalen = strlen ( $ data ) ; $ tag = gmp_init ( 0 , 10 ) ; while ( true ) { if ( $ offset >= $ datalen ) { throw new DecodeException ( "Unexpected end of data while decoding" . " long form identifier." ) ; } $ byte = ord ( $ data [ $ offset ++ ] ) ; $ tag <<= 7 ; $ tag |= 0x7f & $ byte ; if ( ! ( 0x80 & $ byte ) ) { break ; } } return gmp_strval ( $ tag , 10 ) ; } | Parse long form tag . |
50,772 | public function withTag ( $ tag ) : Identifier { $ obj = clone $ this ; $ obj -> _tag = new BigInt ( $ tag ) ; return $ obj ; } | Get self with given type tag . |
50,773 | public function add ( $ name , $ text ) { $ params = array ( 'name' => $ name , 'text' => $ text ) ; return $ this -> master -> call ( 'templates/add' , $ params ) ; } | Adding new template |
50,774 | public function getCdrResponse ( $ xml ) { $ this -> reader -> loadXpath ( $ xml ) ; $ cdr = $ this -> createCdr ( ) ; return $ cdr ; } | Get Cdr using DomDocument . |
50,775 | private function getNotes ( ) { $ xpath = $ this -> reader -> getXpath ( ) ; $ nodes = $ xpath -> query ( $ this -> reader -> getRoot ( ) . '/cbc:Note' ) ; $ notes = [ ] ; if ( $ nodes -> length === 0 ) { return $ notes ; } foreach ( $ nodes as $ node ) { $ notes [ ] = $ node -> nodeValue ; } return $ notes ; } | Get Notes if exist . |
50,776 | protected function argumentName ( ) { if ( $ this -> settings ) { return str_replace ( $ this -> settings [ 'postfix' ] , '' , $ this -> argument ( 'name' ) ) ; } return $ this -> argument ( 'name' ) ; } | Get the argument name of the file that needs to be generated If settings exist remove the postfix from the file |
50,777 | public function add ( $ type , $ params ) { $ params = array_merge ( array ( 'type' => $ type ) , $ params ) ; return $ this -> master -> call ( 'files/add' , $ params ) ; } | Add new file |
50,778 | public function delete ( $ id , $ type ) { $ params = array ( 'id' => $ id , 'type' => $ type ) ; return $ this -> master -> call ( 'files/delete' , $ params ) ; } | Deleting a file |
50,779 | public function setSettings ( ) { $ type = $ this -> option ( 'type' ) ; $ options = config ( 'generators.settings' ) ; $ found = false ; foreach ( $ options as $ key => $ settings ) { if ( $ type == $ key ) { $ found = true ; break ; } } if ( $ found === false ) { $ this -> error ( 'Oops!, no settings key by the type name provided' ) ; exit ; } $ defaults = config ( 'generators.defaults' ) ; foreach ( $ defaults as $ key => $ value ) { if ( ! isset ( $ settings [ $ key ] ) ) { $ settings [ $ key ] = $ defaults [ $ key ] ; } } $ this -> settings = $ settings ; } | Find the type s settings and set local var |
50,780 | public function settingsKey ( $ key ) { if ( is_array ( $ this -> settings ) == false || isset ( $ this -> settings [ $ key ] ) == false ) { return false ; } return $ this -> settings [ $ key ] ; } | Return false or the value for given key from the settings |
50,781 | public static function fromBitString ( BitString $ bs , int $ width ) : self { $ num_bits = $ bs -> numBits ( ) ; $ num = gmp_import ( $ bs -> string ( ) , 1 , GMP_MSW_FIRST | GMP_BIG_ENDIAN ) ; $ num >>= $ bs -> unusedBits ( ) ; if ( $ num_bits < $ width ) { $ num <<= ( $ width - $ num_bits ) ; } return new self ( gmp_strval ( $ num , 10 ) , $ width ) ; } | Initialize from BitString . |
50,782 | public function number ( ) : string { $ num = gmp_import ( $ this -> _flags , 1 , GMP_MSW_FIRST | GMP_BIG_ENDIAN ) ; $ last_octet_bits = $ this -> _width % 8 ; $ unused_bits = $ last_octet_bits ? 8 - $ last_octet_bits : 0 ; $ num >>= $ unused_bits ; return gmp_strval ( $ num , 10 ) ; } | Get flags as a base 10 integer . |
50,783 | public function bitString ( ) : BitString { $ last_octet_bits = $ this -> _width % 8 ; $ unused_bits = $ last_octet_bits ? 8 - $ last_octet_bits : 0 ; return new BitString ( $ this -> _flags , $ unused_bits ) ; } | Get flags as a BitString . Unused bits are set accordingly . Trailing zeroes are not stripped . |
50,784 | public static function fromDER ( string $ data , int & $ offset = null ) : self { $ idx = $ offset ?? 0 ; $ datalen = strlen ( $ data ) ; if ( $ idx >= $ datalen ) { throw new DecodeException ( "Unexpected end of data while decoding length." ) ; } $ indefinite = false ; $ byte = ord ( $ data [ $ idx ++ ] ) ; $ length = ( 0x7f & $ byte ) ; if ( 0x80 & $ byte ) { if ( ! $ length ) { $ indefinite = true ; } else { if ( $ idx + $ length > $ datalen ) { throw new DecodeException ( "Unexpected end of data while decoding long form length." ) ; } $ length = self :: _decodeLongFormLength ( $ length , $ data , $ idx ) ; } } if ( isset ( $ offset ) ) { $ offset = $ idx ; } return new self ( $ length , $ indefinite ) ; } | Decode length component from DER data . |
50,785 | private static function _decodeLongFormLength ( int $ length , string $ data , int & $ offset ) : string { if ( $ length == 127 ) { throw new DecodeException ( "Invalid number of length octets." ) ; } $ num = gmp_init ( 0 , 10 ) ; while ( -- $ length >= 0 ) { $ byte = ord ( $ data [ $ offset ++ ] ) ; $ num <<= 8 ; $ num |= $ byte ; } return gmp_strval ( $ num ) ; } | Decode long form length . |
50,786 | public static function expectFromDER ( string $ data , int & $ offset , int $ expected = null ) : self { $ idx = $ offset ; $ length = self :: fromDER ( $ data , $ idx ) ; if ( isset ( $ expected ) ) { if ( $ length -> isIndefinite ( ) ) { throw new DecodeException ( 'Expected length %d, got indefinite.' , $ expected ) ; } if ( $ expected != $ length -> intLength ( ) ) { throw new DecodeException ( sprintf ( "Expected length %d, got %d." , $ expected , $ length -> intLength ( ) ) ) ; } } if ( ! $ length -> isIndefinite ( ) && strlen ( $ data ) < $ idx + $ length -> intLength ( ) ) { throw new DecodeException ( sprintf ( "Length %d overflows data, %d bytes left." , $ length -> intLength ( ) , strlen ( $ data ) - $ idx ) ) ; } $ offset = $ idx ; return $ length ; } | Decode length from DER . |
50,787 | public function send ( $ phone , $ text , $ gate , $ id ) { $ params = array ( 'phone' => $ phone , 'text' => $ text , 'gate' => $ gate , 'id' => $ id ) ; return $ this -> master -> call ( 'premium/send' , $ params ) ; } | Sending replies for received SMS Premium |
50,788 | public function edit ( $ id , $ name ) { $ params = array ( 'id' => $ id , 'name' => $ name ) ; return $ this -> master -> call ( 'groups/edit' , $ params ) ; } | Editing a group |
50,789 | protected static function _decodeFromDER ( Identifier $ identifier , string $ data , int & $ offset ) : ElementBase { throw new \ BadMethodCallException ( __METHOD__ . " must be implemented in derived class." ) ; } | Decode type - specific element from DER . |
50,790 | public static function fromDER ( string $ data , int & $ offset = null ) : ElementBase { $ idx = $ offset ?? 0 ; $ identifier = Identifier :: fromDER ( $ data , $ idx ) ; $ cls = self :: _determineImplClass ( $ identifier ) ; try { $ element = $ cls :: _decodeFromDER ( $ identifier , $ data , $ idx ) ; } catch ( \ LogicException $ e ) { throw new DecodeException ( sprintf ( "Error while decoding %s." , self :: tagToName ( $ identifier -> intTag ( ) ) ) , 0 , $ e ) ; } $ called_class = get_called_class ( ) ; if ( self :: class != $ called_class ) { if ( ! $ element instanceof $ called_class ) { throw new \ UnexpectedValueException ( sprintf ( "%s expected, got %s." , $ called_class , get_class ( $ element ) ) ) ; } } if ( isset ( $ offset ) ) { $ offset = $ idx ; } return $ element ; } | Decode element from DER data . |
50,791 | private function _isConcreteType ( int $ tag ) : bool { if ( $ this -> tag ( ) != $ tag ) { return false ; } if ( $ this -> typeClass ( ) == Identifier :: CLASS_UNIVERSAL ) { $ cls = self :: _determineUniversalImplClass ( $ tag ) ; if ( ! $ this instanceof $ cls ) { return false ; } } return true ; } | Check whether the element is a concrete type of a given tag . |
50,792 | private function _isPseudoType ( int $ tag ) : bool { switch ( $ tag ) { case self :: TYPE_STRING : return $ this instanceof StringType ; case self :: TYPE_TIME : return $ this instanceof TimeType ; } return false ; } | Check whether the element is a pseudotype . |
50,793 | public function withIndefiniteLength ( bool $ indefinite = true ) : self { $ obj = clone $ this ; $ obj -> _indefiniteLength = $ indefinite ; return $ obj ; } | Get self with indefinite length encoding set . |
50,794 | protected static function _determineImplClass ( Identifier $ identifier ) : string { switch ( $ identifier -> typeClass ( ) ) { case Identifier :: CLASS_UNIVERSAL : return self :: _determineUniversalImplClass ( $ identifier -> intTag ( ) ) ; case Identifier :: CLASS_CONTEXT_SPECIFIC : return ContextSpecificType :: class ; case Identifier :: CLASS_APPLICATION : return ApplicationType :: class ; case Identifier :: CLASS_PRIVATE : return PrivateType :: class ; } throw new \ UnexpectedValueException ( sprintf ( "%s %d not implemented." , Identifier :: classToName ( $ identifier -> typeClass ( ) ) , $ identifier -> tag ( ) ) ) ; } | Determine the class that implements the type . |
50,795 | protected static function _determineUniversalImplClass ( int $ tag ) : string { if ( ! array_key_exists ( $ tag , self :: MAP_TAG_TO_CLASS ) ) { throw new \ UnexpectedValueException ( "Universal tag $tag not implemented." ) ; } return self :: MAP_TAG_TO_CLASS [ $ tag ] ; } | Determine the class that implements an universal type of the given tag . |
50,796 | protected function _typeDescriptorString ( ) : string { if ( $ this -> typeClass ( ) == Identifier :: CLASS_UNIVERSAL ) { return self :: tagToName ( $ this -> _typeTag ) ; } return sprintf ( "%s TAG %d" , Identifier :: classToName ( $ this -> typeClass ( ) ) , $ this -> _typeTag ) ; } | Get textual description of the type for debugging purposes . |
50,797 | public static function tagToName ( int $ tag ) : string { if ( ! array_key_exists ( $ tag , self :: MAP_TYPE_TO_NAME ) ) { return "TAG $tag" ; } return self :: MAP_TYPE_TO_NAME [ $ tag ] ; } | Get human readable name for an universal tag . |
50,798 | public function check ( $ phone , $ id = null ) { $ params = array ( 'phone' => $ phone , 'id' => $ id ) ; return $ this -> master -> call ( 'phones/check' , $ params ) ; } | Checking phone in to HLR |
50,799 | public function sendRequest ( $ data ) { return $ this -> httpClient -> request ( $ this -> getHttpMethod ( ) , $ this -> getEndpoint ( ) , [ 'Accept' => 'application/json' , 'Authorization' => $ this -> getServiceKey ( ) , 'Content-Type' => 'application/json' , ] , json_encode ( $ data ) ) ; } | Make the actual request to WorldPay |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.