idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
59,500
protected function execute ( InputInterface $ input , OutputInterface $ output ) { try { $ currentVersion = Context :: get ( 'version-persister' ) -> getCurrentVersion ( ) ; } catch ( \ Liip \ RMT \ Exception \ NoReleaseFoundException $ e ) { if ( Context :: get ( 'information-collector' ) -> getValueFor ( 'confirm-fir...
Always executed but first initialize and interact have already been called
59,501
protected function getRemote ( ) { if ( $ this -> options [ 'ask-remote-name' ] ) { return Context :: get ( 'information-collector' ) -> getValueFor ( 'remote' ) ; } if ( $ this -> options [ 'remote-name' ] !== null ) { return $ this -> options [ 'remote-name' ] ; } return ; }
Return the remote name where to publish or null if not defined
59,502
protected function create ( ) { $ this -> setReleaseVersion ( ) ; $ output = $ this -> getDestination ( ) . '/' . $ this -> getFilename ( ) ; $ phar = new Phar ( $ output , FilesystemIterator :: CURRENT_AS_FILEINFO | FilesystemIterator :: KEY_AS_FILENAME ) ; $ phar -> buildFromDirectory ( Context :: getParam ( 'project...
Handles the creation of the package .
59,503
protected function getDestination ( ) { $ destination = $ this -> options [ 'destination' ] ; if ( $ this -> isRelativePath ( $ destination ) ) { return Context :: getParam ( 'project-root' ) . '/' . $ destination ; } return $ destination ; }
Get the destination directory to build the package into .
59,504
protected function setReleaseVersion ( ) { try { $ currentVersion = Context :: get ( 'version-persister' ) -> getCurrentVersion ( ) ; } catch ( \ Exception $ e ) { $ currentVersion = Context :: get ( 'version-generator' ) -> getInitialVersion ( ) ; } $ this -> releaseVersion = Context :: get ( 'version-generator' ) -> ...
Determine and set the next release version .
59,505
public function getValidVersionTags ( $ versionRegex ) { $ validator = new TagValidator ( $ versionRegex , $ this -> getTagPrefix ( ) ) ; return $ validator -> filtrateList ( $ this -> vcs -> getTags ( ) ) ; }
Return all tags matching the versionRegex and prefix
59,506
protected function getNewLines ( $ type , $ version , $ comment ) { list ( $ major , $ minor , $ patch ) = explode ( '.' , $ version ) ; if ( $ type == 'major' ) { $ title = "version $major $comment" ; return array_merge ( array ( '' , strtoupper ( $ title ) , str_pad ( '' , strlen ( $ title ) , '=' ) , ) , $ this -> ...
Return the new formatted lines for the given variables
59,507
protected function findPositionToInsert ( $ lines , $ type ) { if ( $ type == 'major' ) { return 0 ; } if ( $ type == 'minor' ) { foreach ( $ lines as $ pos => $ line ) { if ( preg_match ( '/^=======/' , $ line ) ) { return $ pos + 1 ; } } } if ( $ type == 'patch' ) { foreach ( $ lines as $ pos => $ line ) { if ( preg_...
Return the position where to insert new lines according to the type of insertion
59,508
public function executeCommandInProcess ( $ cmd , $ timeout = null ) { Context :: get ( 'output' ) -> write ( "<comment>$cmd</comment>\n\n" ) ; $ process = new Process ( $ cmd ) ; if ( $ timeout !== null ) { $ process -> setTimeout ( $ timeout ) ; } $ process -> run ( function ( $ type , $ buffer ) { Context :: get ( '...
Execute a command and render the output through the classical indented output
59,509
public function setStream ( $ stream = null ) { if ( is_string ( $ stream ) ) { $ stream = @ fopen ( $ stream , 'a' ) ; } if ( ! is_resource ( $ stream ) ) { throw new \ InvalidArgumentException ( 'Invalid Stream' ) ; } $ this -> stream = $ stream ; return $ this ; }
Set the stream to write to
59,510
public function getParameterBytes ( $ asString = true ) { if ( $ asString === true ) { return implode ( $ this -> parameterBytes ) ; } else { return $ this -> parameterBytes ; } }
Get the Parameter Byte
59,511
public function flush ( $ resetAfterwards = true ) { if ( $ this -> writer instanceof Writers \ FlushableInterface ) { return $ this -> writer -> flush ( $ resetAfterwards ) ; } else { throw new \ Exception ( 'Flushing a non FlushableInterface is not possible' ) ; } }
Flush the contents of the writer
59,512
public function e ( $ resetAfterwards = true ) { try { echo $ this -> flush ( $ resetAfterwards ) ; return $ this ; } catch ( \ Exception $ e ) { throw $ e ; } }
Echo the contents of the writer
59,513
public function setControlSequenceIntroducer ( $ controlSequenceIntroducer ) { if ( is_string ( $ controlSequenceIntroducer ) ) { $ controlSequenceIntroducer = new ControlFunction ( $ controlSequenceIntroducer ) ; } $ this -> controlSequenceIntroducer = $ controlSequenceIntroducer ; return $ this ; }
Set the control sequence introducer
59,514
public function get ( ) { $ toReturn = '' ; $ toReturn = $ this -> controlSequenceIntroducer -> get ( ) . '[' ; if ( isset ( $ this -> parameterBytes ) && sizeof ( ( array ) $ this -> parameterBytes ) > 0 ) { $ toReturn .= implode ( $ this -> parameterBytes , ';' ) ; } if ( isset ( $ this -> intermediateBytes ) && size...
Build and return the ANSI Code
59,515
public function getIntermediateBytes ( $ asString = true ) { if ( $ asString === true ) { return implode ( $ this -> intermediateBytes ) ; } else { return $ this -> intermediateBytes ; } }
Get the Intermediate Byte
59,516
private function loadMethodLevelAnnotations ( object $ service ) : AnnotationCollection { return $ this -> annotationReader -> extract ( \ get_class ( $ service ) ) -> filter ( static function ( Annotation $ annotation ) : ? Annotation { if ( $ annotation -> annotationObject instanceof ServicesAnnotationsMarker ) { ret...
Load a list of annotations for message handlers .
59,517
public function enableValidation ( array $ validationGroups = [ ] ) : self { $ defaultValidationFailedEvent = $ this -> defaultValidationFailedEvent ; $ defaultThrowableEvent = $ this -> defaultThrowableEvent ; return new self ( $ this -> isEventListener , $ this -> isCommandHandler , true , $ validationGroups , $ defa...
Enable validation .
59,518
public function addCompilerPasses ( CompilerPassInterface ... $ compilerPasses ) : void { foreach ( $ compilerPasses as $ compilerPass ) { $ this -> compilerPasses -> attach ( $ compilerPass ) ; } }
Add customer compiler pass .
59,519
public function addExtensions ( Extension ... $ extensions ) : void { foreach ( $ extensions as $ extension ) { $ this -> extensions -> attach ( $ extension ) ; } }
Add customer extension .
59,520
public function addModules ( ServiceBusModule ... $ serviceBusModules ) : void { foreach ( $ serviceBusModules as $ serviceBusModule ) { $ this -> modules -> attach ( $ serviceBusModule ) ; } }
Add customer modules .
59,521
public function hasActualContainer ( ) : bool { if ( false === $ this -> environment -> isDebug ( ) ) { return true === $ this -> configCache ( ) -> isFresh ( ) ; } return false ; }
Has compiled actual container .
59,522
public function cachedContainer ( ) : ContainerInterface { include_once $ this -> getContainerClassPath ( ) ; $ containerClassName = $ this -> getContainerClassName ( ) ; $ container = new $ containerClassName ( ) ; return $ container ; }
Receive cached container .
59,523
public function build ( ) : ContainerInterface { $ this -> parameters [ 'service_bus.environment' ] = ( string ) $ this -> environment ; $ this -> parameters [ 'service_bus.entry_point' ] = $ this -> entryPointName ; $ containerBuilder = new SymfonyContainerBuilder ( new ParameterBag ( $ this -> parameters ) ) ; foreac...
Build container .
59,524
private function dumpContainer ( SymfonyContainerBuilder $ builder ) : void { $ dumper = new PhpDumper ( $ builder ) ; $ content = $ dumper -> dump ( [ 'class' => $ this -> getContainerClassName ( ) , 'base_class' => 'Container' , 'file' => $ this -> configCache ( ) -> getPath ( ) , ] ) ; if ( true === \ is_string ( $ ...
Save container .
59,525
private function configCache ( ) : ConfigCache { if ( null === $ this -> configCache ) { $ this -> configCache = new ConfigCache ( $ this -> getContainerClassPath ( ) , $ this -> environment -> isDebug ( ) ) ; } return $ this -> configCache ; }
Receive config cache .
59,526
private function cacheDirectory ( ) : string { $ cacheDirectory = ( string ) $ this -> cacheDirectory ; if ( '' === $ cacheDirectory && false === \ is_writable ( $ cacheDirectory ) ) { $ cacheDirectory = \ sys_get_temp_dir ( ) ; } return \ rtrim ( $ cacheDirectory , '/' ) ; }
Receive cache directory path .
59,527
private function getContainerClassName ( ) : string { return \ sprintf ( self :: CONTAINER_NAME_TEMPLATE , \ lcfirst ( $ this -> entryPointName ) , \ ucfirst ( ( string ) $ this -> environment ) ) ; }
Get container class name .
59,528
public function listen ( Queue ... $ queues ) : Promise { $ isTestCall = 'phpunitTests' === ( string ) \ getenv ( 'SERVICE_BUS_TESTING' ) ; return call ( function ( array $ queues ) use ( $ isTestCall ) : \ Generator { yield $ this -> transport -> consume ( function ( IncomingPackage $ package ) use ( $ isTestCall ) : ...
Start queues listen .
59,529
public function stop ( int $ delay = 10 ) : void { $ delay = 0 >= $ delay ? 1 : $ delay ; Loop :: defer ( function ( ) use ( $ delay ) : \ Generator { yield $ this -> transport -> stop ( ) ; $ this -> logger -> info ( 'Handler will stop after {duration} seconds' , [ 'duration' => $ delay ] ) ; Loop :: delay ( $ delay *...
Unsubscribe all queues . Terminates the subscription and stops the daemon after the specified number of seconds .
59,530
public function createTopic ( Topic $ topic , TopicBind ... $ binds ) : Promise { return $ this -> transport -> createTopic ( $ topic , ... $ binds ) ; }
Create topic and bind them If the topic to which we binds does not exist it will be created .
59,531
public function useDefaultStopSignalHandler ( int $ stopDelay = 10 , array $ signals = [ \ SIGINT , \ SIGTERM ] ) : self { $ stopDelay = 0 >= $ stopDelay ? 1 : $ stopDelay ; $ logger = $ this -> getKernelContainerService ( 'service_bus.logger' ) ; $ handler = function ( string $ watcherId , int $ signalId ) use ( $ sto...
Use default handler for signal SIGINT and SIGTERM .
59,532
public function stopAfter ( int $ seconds ) : self { $ seconds = 0 >= $ seconds ? 1 : $ seconds ; Loop :: delay ( $ seconds * 1000 , function ( ) use ( $ seconds ) : void { $ logger = $ this -> getKernelContainerService ( 'service_bus.logger' ) ; $ logger -> info ( 'The demon\'s lifetime has expired ({lifetime} seconds...
Shut down after N seconds .
59,533
public function stopWhenFilesChange ( string $ directoryPath , int $ checkInterval = 30 , int $ stopDelay = 5 ) : self { $ checkInterval = 0 >= $ checkInterval ? 1 : $ checkInterval ; $ watcher = new FileChangesWatcher ( $ directoryPath ) ; Loop :: repeat ( $ checkInterval * 1000 , function ( ) use ( $ watcher , $ stop...
Enable file change monitoring . If the application files have been modified quit .
59,534
public function registerEndpointForMessages ( Endpoint $ endpoint , string ... $ messages ) : self { $ entryPointRouter = $ this -> getKernelContainerService ( EndpointRouter :: class ) ; foreach ( $ messages as $ messageClass ) { $ entryPointRouter -> registerRoute ( $ messageClass , $ endpoint ) ; } return $ this ; }
Apply specific route to deliver a messages By default messages will be sent to the application transport . If a different option is specified for the message it will be sent only to it .
59,535
public function registerDestinationForMessages ( DeliveryDestination $ deliveryDestination , string ... $ messages ) : self { $ applicationEndpoint = $ this -> getKernelContainerService ( Endpoint :: class ) ; $ newEndpoint = $ applicationEndpoint -> withNewDeliveryDestination ( $ deliveryDestination ) ; return $ this ...
Like the registerEndpointForMessages method it adds a custom message delivery route . The only difference is that the route is specified for the current application transport .
59,536
public function enableAutoImportMessageHandlers ( array $ directories , array $ excludedFiles = [ ] ) : self { $ this -> importParameters ( [ 'service_bus.auto_import.handlers_enabled' => true , 'service_bus.auto_import.handlers_directories' => $ directories , 'service_bus.auto_import.handlers_excluded' => $ excludedFi...
All message handlers from the specified directories will be registered automatically .
59,537
public function boot ( ) : ContainerInterface { $ this -> containerBuilder -> addCompilerPasses ( new TaggedMessageHandlersCompilerPass ( ) , new ServiceLocatorTagPass ( ) ) ; return $ this -> containerBuilder -> build ( ) ; }
Compile container .
59,538
public static function create ( string $ environment ) : self { $ environment = \ strtolower ( $ environment ) ; self :: validateEnvironment ( $ environment ) ; return new self ( $ environment ) ; }
Creating the specified environment .
59,539
private static function validateEnvironment ( string $ specifiedEnvironment ) : void { if ( '' === $ specifiedEnvironment || false === \ in_array ( $ specifiedEnvironment , self :: LIST , true ) ) { throw new \ LogicException ( \ sprintf ( 'Provided incorrect value of the environment: "%s". Allowable values: %s' , $ sp...
Validate the specified environment .
59,540
public function registerRoutes ( array $ messages , Endpoint $ endpoint ) : void { foreach ( $ messages as $ message ) { $ this -> registerRoute ( $ message , $ endpoint ) ; } }
Add custom endpoint for multiple messages .
59,541
public function registerRoute ( string $ messageClass , Endpoint $ endpoint ) : void { $ this -> routes [ $ messageClass ] [ ] = $ endpoint ; }
Add custom endpoint to specified message .
59,542
public function route ( string $ messageClass ) : array { if ( false === empty ( $ this -> routes [ $ messageClass ] ) ) { return $ this -> routes [ $ messageClass ] ; } return $ this -> globalEndpoints ; }
Receiving a message sending route If no specific route is registered the default endpoint route will be returned .
59,543
public function compare ( ) : Promise { return call ( function ( ) : \ Generator { $ bufferContent = yield from self :: execute ( $ this -> directory ) ; $ hash = self :: extractHash ( $ bufferContent ) ; if ( null === $ hash ) { return false ; } if ( null !== $ this -> previousHash && $ this -> previousHash !== $ hash...
Compare hashes If returned false the files have not been changed . Otherwise return true .
59,544
private static function execute ( string $ directory ) : \ Generator { try { $ process = new Process ( \ sprintf ( 'find %s -name \'*.php\' \( -exec sha1sum "$PWD"/{} \; -o -print \) | sha1sum' , $ directory ) ) ; yield $ process -> start ( ) ; $ bufferContent = yield buffer ( $ process -> getStdout ( ) ) ; return $ bu...
Execute calculate hashes .
59,545
private static function extractHash ( string $ response ) : ? string { $ parts = \ array_map ( 'trim' , \ explode ( ' ' , $ response ) ) ; return $ parts [ 0 ] ?? null ; }
Get a hash from the stdOut .
59,546
private static function createPackage ( string $ payload , DeliveryOptions $ options , DeliveryDestination $ destination ) : OutboundPackage { return OutboundPackage :: create ( $ payload , $ options -> headers ( ) , $ destination , $ options -> traceId ( ) , $ options -> isPersistent ( ) , false , false , $ options ->...
Create outbound package with specified parameters .
59,547
private static function publishViolations ( string $ eventClass , ServiceBusContext $ context ) : Promise { $ event = \ forward_static_call_array ( [ $ eventClass , 'create' ] , [ $ context -> traceId ( ) , $ context -> violations ( ) ] ) ; return $ context -> delivery ( $ event ) ; }
Publish failed event .
59,548
private static function bindViolations ( ConstraintViolationList $ violations , ServiceBusContext $ context ) : void { $ errors = [ ] ; foreach ( $ violations as $ violation ) { $ errors [ $ violation -> getPropertyPath ( ) ] [ ] = $ violation -> getMessage ( ) ; } try { invokeReflectionMethod ( $ context , 'validation...
Bind violations to context .
59,549
private static function publishThrowable ( string $ eventClass , string $ errorMessage , KernelContext $ context ) : \ Generator { $ event = \ forward_static_call_array ( [ $ eventClass , 'create' ] , [ $ context -> traceId ( ) , $ errorMessage ] ) ; yield $ context -> delivery ( $ event ) ; }
Publish failed response event .
59,550
private static function collectArguments ( \ SplObjectStorage $ arguments , array $ resolvers , object $ message , KernelContext $ context ) : array { $ preparedArguments = [ ] ; foreach ( $ arguments as $ argument ) { foreach ( $ resolvers as $ argumentResolver ) { if ( true === $ argumentResolver -> supports ( $ argu...
Collect arguments list .
59,551
protected function createTransport ( array $ config ) { if ( ! isset ( $ config [ 'class' ] ) ) { $ config [ 'class' ] = 'Swift_SendmailTransport' ; } if ( isset ( $ config [ 'plugins' ] ) ) { $ plugins = $ config [ 'plugins' ] ; unset ( $ config [ 'plugins' ] ) ; } else { $ plugins = [ ] ; } if ( $ this -> enableSwift...
Creates email transport instance by its array configuration .
59,552
protected function createSwiftObject ( array $ config ) { if ( isset ( $ config [ 'class' ] ) ) { $ className = $ config [ 'class' ] ; unset ( $ config [ 'class' ] ) ; } else { throw new InvalidConfigException ( 'Object configuration must be an array containing a "class" element.' ) ; } if ( isset ( $ config [ 'constru...
Creates Swift library object from given array configuration .
59,553
protected function setBody ( $ body , $ contentType ) { $ message = $ this -> getSwiftMessage ( ) ; $ oldBody = $ message -> getBody ( ) ; $ charset = $ message -> getCharset ( ) ; if ( empty ( $ oldBody ) ) { $ parts = $ message -> getChildren ( ) ; $ partFound = false ; foreach ( $ parts as $ key => $ part ) { if ( !...
Sets the message body . If body is already set and its content type matches given one it will be overridden if content type miss match the multipart message will be composed .
59,554
public function setSignature ( $ signature ) { if ( ! empty ( $ this -> signers ) ) { $ swiftMessage = $ this -> getSwiftMessage ( ) ; foreach ( $ this -> signers as $ signer ) { $ swiftMessage -> detachSigner ( $ signer ) ; } $ this -> signers = [ ] ; } return $ this -> addSignature ( $ signature ) ; }
Sets message signature
59,555
protected function createSwiftSigner ( $ signature ) { if ( ! isset ( $ signature [ 'type' ] ) ) { throw new InvalidConfigException ( 'Signature configuration should contain "type" key' ) ; } switch ( strtolower ( $ signature [ 'type' ] ) ) { case 'dkim' : $ domain = ArrayHelper :: getValue ( $ signature , 'domain' , n...
Creates signer from its configuration
59,556
public function addHeader ( $ name , $ value ) { $ this -> getSwiftMessage ( ) -> getHeaders ( ) -> addTextHeader ( $ name , $ value ) ; return $ this ; }
Adds custom header value to the message . Several invocations of this method with the same name will add multiple header values .
59,557
public function setHeader ( $ name , $ value ) { $ headerSet = $ this -> getSwiftMessage ( ) -> getHeaders ( ) ; if ( $ headerSet -> has ( $ name ) ) { $ headerSet -> remove ( $ name ) ; } foreach ( ( array ) $ value as $ v ) { $ headerSet -> addTextHeader ( $ name , $ v ) ; } return $ this ; }
Sets custom header value to the message .
59,558
public function getHeader ( $ name ) { $ headerSet = $ this -> getSwiftMessage ( ) -> getHeaders ( ) ; if ( ! $ headerSet -> has ( $ name ) ) { return [ ] ; } $ headers = [ ] ; foreach ( $ headerSet -> getAll ( $ name ) as $ header ) { $ headers [ ] = $ header -> getValue ( ) ; } return $ headers ; }
Returns all values for the specified header .
59,559
public static function wrap ( $ n , $ min , $ max ) { return ( $ n >= $ min && $ n < $ max ) ? $ n : ( self :: mod ( $ n - $ min , $ max - $ min ) + $ min ) ; }
Wraps the given value into the inclusive - exclusive interval between min and max .
59,560
public static function computeHeading ( $ from , $ to ) { $ fromLat = deg2rad ( $ from [ 'lat' ] ) ; $ fromLng = deg2rad ( $ from [ 'lng' ] ) ; $ toLat = deg2rad ( $ to [ 'lat' ] ) ; $ toLng = deg2rad ( $ to [ 'lng' ] ) ; $ dLng = $ toLng - $ fromLng ; $ heading = atan2 ( sin ( $ dLng ) * cos ( $ toLat ) , cos ( $ from...
Returns the heading from one LatLng to another LatLng . Headings are expressed in degrees clockwise from North within the range [ - 180 180 ) .
59,561
public static function computeOffsetOrigin ( $ to , $ distance , $ heading ) { $ heading = deg2rad ( $ heading ) ; $ distance /= MathUtil :: EARTH_RADIUS ; $ n1 = cos ( $ distance ) ; $ n2 = sin ( $ distance ) * cos ( $ heading ) ; $ n3 = sin ( $ distance ) * sin ( $ heading ) ; $ n4 = sin ( rad2deg ( $ to [ 'lat' ] ) ...
Returns the location of origin when provided with a LatLng destination meters travelled and original heading . Headings are expressed in degrees clockwise from North . This function returns null when no solution is available .
59,562
public static function interpolate ( $ from , $ to , $ fraction ) { $ fromLat = deg2rad ( $ from [ 'lat' ] ) ; $ fromLng = deg2rad ( $ from [ 'lng' ] ) ; $ toLat = deg2rad ( $ to [ 'lat' ] ) ; $ toLng = deg2rad ( $ to [ 'lng' ] ) ; $ cosFromLat = cos ( $ fromLat ) ; $ cosToLat = cos ( $ toLat ) ; $ angle = self :: comp...
Returns the LatLng which lies the given fraction of the way between the origin LatLng and the destination LatLng .
59,563
private static function distanceRadians ( $ lat1 , $ lng1 , $ lat2 , $ lng2 ) { return MathUtil :: arcHav ( MathUtil :: havDistance ( $ lat1 , $ lat2 , $ lng1 - $ lng2 ) ) ; }
Returns distance on the unit sphere ; the arguments are in radians .
59,564
private static function computeAngleBetween ( $ from , $ to ) { return self :: distanceRadians ( deg2rad ( $ from [ 'lat' ] ) , deg2rad ( $ from [ 'lng' ] ) , deg2rad ( $ to [ 'lat' ] ) , deg2rad ( $ to [ 'lng' ] ) ) ; }
Returns the angle between two LatLngs in radians . This is the same as the distance on the unit sphere .
59,565
public static function computeLength ( $ path ) { if ( count ( $ path ) < 2 ) { return 0 ; } $ length = 0 ; $ prev = $ path [ 0 ] ; $ prevLat = deg2rad ( $ prev [ 'lat' ] ) ; $ prevLng = deg2rad ( $ prev [ 'lng' ] ) ; foreach ( $ path as $ point ) { $ lat = deg2rad ( $ point [ 'lat' ] ) ; $ lng = deg2rad ( $ point [ 'l...
Returns the length of the given path in meters on Earth .
59,566
private static function computeSignedAreaP ( $ path , $ radius ) { $ size = count ( $ path ) ; if ( $ size < 3 ) { return 0 ; } $ total = 0 ; $ prev = $ path [ $ size - 1 ] ; $ prevTanLat = tan ( ( M_PI / 2 - deg2rad ( $ prev [ 'lat' ] ) ) / 2 ) ; $ prevLng = deg2rad ( $ prev [ 'lng' ] ) ; foreach ( $ path as $ point )...
Returns the signed area of a closed path on a sphere of given radius . The computed area uses the same units as the radius squared . Used by SphericalUtilTest .
59,567
public static function distanceToLine ( $ p , $ start , $ end ) { if ( $ start == $ end ) { return SphericalUtil :: computeDistanceBetween ( $ end , $ p ) ; } $ s0lat = deg2rad ( $ p [ 'lat' ] ) ; $ s0lng = deg2rad ( $ p [ 'lng' ] ) ; $ s1lat = deg2rad ( $ start [ 'lat' ] ) ; $ s1lng = deg2rad ( $ start [ 'lng' ] ) ; $...
Computes the distance on the sphere between the point p and the line segment start to end .
59,568
public static function decode ( $ encodedPath ) { $ len = strlen ( $ encodedPath ) - 1 ; $ path = [ ] ; $ index = 0 ; $ lat = 0 ; $ lng = 0 ; while ( $ index < $ len ) { $ result = 1 ; $ shift = 0 ; $ b ; do { $ b = ord ( $ encodedPath { $ index ++ } ) - 63 - 1 ; $ result += $ b << $ shift ; $ shift += 5 ; } while ( $ ...
Decodes an encoded path string into a sequence of LatLngs .
59,569
public static function encode ( $ path ) { $ lastLat = 0 ; $ lastLng = 0 ; $ result = '' ; foreach ( $ path as $ point ) { $ lat = round ( $ point [ 'lat' ] * 1e5 ) ; $ lng = round ( $ point [ 'lng' ] * 1e5 ) ; $ dLat = $ lat - $ lastLat ; $ dLng = $ lng - $ lastLng ; self :: enc ( $ dLat ) ; self :: enc ( $ dLng ) ; $...
Encodes a sequence of LatLngs into an encoded path string .
59,570
public static function prompt ( ) { $ stdin = fopen ( 'php://stdin' , 'r' ) ; $ answer = self :: trimAnswer ( fgets ( $ stdin , 4096 ) ) ; fclose ( $ stdin ) ; return $ answer ; }
Prompts the user for input and shows what they type
59,571
public static function hiddenPrompt ( $ allowFallback = false ) { if ( defined ( 'PHP_WINDOWS_VERSION_BUILD' ) ) { $ exe = __DIR__ . '\\..\\res\\hiddeninput.exe' ; if ( 'phar:' === substr ( __FILE__ , 0 , 5 ) ) { $ tmpExe = sys_get_temp_dir ( ) . '/hiddeninput.exe' ; $ source = fopen ( $ exe , 'r' ) ; $ target = fopen ...
Prompts the user for input and hides what they type
59,572
public function observers ( ) : array { if ( $ this -> shouldIgnore ( ) ) { return [ ] ; } $ observers = [ ] ; foreach ( $ this -> getManifest ( ) as $ name => $ extra ) { $ observers = array_merge ( $ observers , $ extra [ 'observers' ] ?? [ ] ) ; } return array_map ( [ $ this , 'listObserver' ] , array_filter ( $ obs...
Get observers .
59,573
protected function validateObserver ( $ observer ) : bool { return ! $ this -> isDisable ( $ observer ) && ( new ReflectionClass ( $ observer ) ) -> implementsInterface ( EventHandlerInterface :: class ) && $ this -> accessible ( $ observer ) ; }
Validate the given observer .
59,574
protected function accessible ( $ observer ) : bool { if ( ! method_exists ( $ observer , 'getAccessor' ) ) { return true ; } return in_array ( get_class ( $ this -> app ) , ( array ) $ observer :: getAccessor ( ) ) ; }
Determine whether the given observer is accessible .
59,575
protected function getManifest ( ) : array { if ( ! is_null ( $ this -> manifest ) ) { return $ this -> manifest ; } return $ this -> manifest = file_exists ( $ this -> manifestPath ) ? require $ this -> manifestPath : [ ] ; }
Get the easywechat manifest .
59,576
public function cleanUp ( ) { $ composerBinDirectory = $ this -> configuration -> getComposerBinDirectory ( ) ; if ( false === is_dir ( $ composerBinDirectory ) ) { $ this -> helper -> getFilesystem ( ) -> createDirectory ( $ composerBinDirectory ) ; } $ this -> removeFromDir ( $ composerBinDirectory ) ; $ this -> remo...
Removes symlinks from composer s bin - dir and old phar s from own bin - dir .
59,577
private function getDecisions ( ) { return [ new OnlyDevDecision ( $ this -> configuration , $ this -> helper ) , new IsAccessibleDecision ( $ this -> configuration , $ this -> helper ) , new FileAlreadyExistDecision ( $ this -> configuration , $ this -> helper ) , new IsVerifiedDecision ( $ this -> configuration , $ t...
Each decision can interrupt the download of a tool .
59,578
public function checkNotificationSignature ( $ signature , array $ notificationBody , $ merchantSecret ) { $ notificationBody = array_replace_recursive ( [ 'bill' => [ 'billId' => null , 'amount' => [ 'value' => null , 'currency' => null , ] , 'siteId' => null , 'status' => [ 'value' => null ] , ] , ] , $ notificationB...
Checks notification data signature .
59,579
public function getLifetimeByDay ( $ days = 45 ) { $ dateTime = new DateTime ( ) ; return $ this -> normalizeDate ( $ dateTime -> modify ( '+' . max ( 1 , $ days ) . ' days' ) ) ; }
Generate lifetime in format .
59,580
public function getPayUrl ( array $ bill , $ successUrl ) { $ bill = array_replace ( [ 'payUrl' => null ] , $ bill ) ; $ payUrl = parse_url ( ( string ) $ bill [ 'payUrl' ] ) ; if ( true === array_key_exists ( 'query' , $ payUrl ) ) { parse_str ( $ payUrl [ 'query' ] , $ query ) ; $ query [ 'successUrl' ] = $ successUr...
Get pay URL witch success URL param .
59,581
public function createPaymentForm ( array $ params ) { $ params = array_replace_recursive ( [ 'billId' => null , 'publicKey' => null , 'amount' => null , 'successUrl' => null , 'customFields' => [ ] , ] , $ params ) ; $ params [ 'amount' ] = $ this -> normalizeAmount ( $ params [ 'amount' ] ) ; $ params [ 'customFields...
Creating checkout link .
59,582
public function createBill ( $ billId , array $ params ) { $ params = array_replace_recursive ( [ 'amount' => null , 'currency' => null , 'comment' => null , 'expirationDateTime' => null , 'phone' => null , 'email' => null , 'account' => null , 'successUrl' => null , 'customFields' => [ 'apiClient' => CLIENT_NAME , 'ap...
Creating bill .
59,583
public function refund ( $ billId , $ refundId , $ amount = '0' , $ currency = 'RUB' ) { return $ this -> requestBuilder ( $ billId . '/refunds/' . $ refundId , self :: PUT , [ 'amount' => [ 'currency' => ( string ) $ currency , 'value' => $ this -> normalizeAmount ( $ amount ) , ] , ] ) ; }
Refund paid bill .
59,584
protected function requestBuilder ( $ uri , $ method = self :: GET , array $ body = [ ] ) { $ this -> internalCurl -> reset ( ) ; foreach ( $ this -> options as $ option => $ value ) { $ this -> internalCurl -> setOpt ( $ option , $ value ) ; } $ url = self :: BILLS_URI . $ uri ; $ this -> internalCurl -> setHeader ( '...
Build request .
59,585
protected function buildUrl ( array $ parsedUrl ) { if ( true === isset ( $ parsedUrl [ 'scheme' ] ) ) { $ scheme = $ parsedUrl [ 'scheme' ] . '://' ; } else { $ scheme = '' ; } if ( true === isset ( $ parsedUrl [ 'host' ] ) ) { $ host = $ parsedUrl [ 'host' ] ; } else { $ host = '' ; } if ( true === isset ( $ parsedUr...
Build URL .
59,586
protected function configure ( ) { $ this -> setName ( 'check' ) -> setDescription ( 'Check PHP files within a directory for appropriate use of Docblocks.' ) -> addOption ( 'exclude' , 'x' , InputOption :: VALUE_REQUIRED , 'Files and directories to exclude.' ) -> addOption ( 'directory' , 'd' , InputOption :: VALUE_REQ...
Configure the console command add options etc .
59,587
protected function statementsContainReturn ( array $ statements ) { foreach ( $ statements as $ statement ) { if ( $ statement instanceof Stmt \ Return_ ) { return true ; } if ( empty ( $ statement -> stmts ) ) { continue ; } if ( $ this -> statementsContainReturn ( $ statement -> stmts ) ) { return true ; } } return f...
Recursively search an array of statements for a return statement .
59,588
public function parseOption ( $ optionName ) { return $ this -> input -> getOption ( $ optionName ) || isset ( $ this -> fileConfig [ 'options' ] [ $ optionName ] ) ; }
If the option is set in either the command line or config file return true
59,589
public function addComponent ( IComponent $ component , $ name , $ insertBefore = NULL ) { if ( $ name === NULL ) { $ name = $ component -> getName ( ) ; } if ( is_int ( $ name ) ) { $ name = ( string ) $ name ; } elseif ( ! is_string ( $ name ) ) { throw new Nette \ InvalidArgumentException ( sprintf ( 'Component name...
Adds the specified component to the IContainer .
59,590
public function removeComponent ( IComponent $ component ) { $ name = $ component -> getName ( ) ; if ( ! isset ( $ this -> components [ $ name ] ) || $ this -> components [ $ name ] !== $ component ) { throw new Nette \ InvalidArgumentException ( "Component named '$name' is not located in this container." ) ; } unset ...
Removes a component from the IContainer .
59,591
public function getComponent ( $ name , $ need = TRUE ) { if ( isset ( $ this -> components [ $ name ] ) ) { return $ this -> components [ $ name ] ; } if ( is_int ( $ name ) ) { $ name = ( string ) $ name ; } elseif ( ! is_string ( $ name ) ) { throw new Nette \ InvalidArgumentException ( sprintf ( 'Component name mus...
Returns component specified by name or path .
59,592
public function getComponents ( $ deep = FALSE , $ filterType = NULL ) { $ iterator = new RecursiveComponentIterator ( $ this -> components ) ; if ( $ deep ) { $ deep = $ deep > 0 ? \ RecursiveIteratorIterator :: SELF_FIRST : \ RecursiveIteratorIterator :: CHILD_FIRST ; $ iterator = new \ RecursiveIteratorIterator ( $ ...
Iterates over components .
59,593
public function getParameter ( $ name , $ default = NULL ) { if ( isset ( $ this -> params [ $ name ] ) ) { return $ this -> params [ $ name ] ; } else { return $ default ; } }
Returns component param .
59,594
public function getParameterId ( $ name ) { $ uid = $ this -> getUniqueId ( ) ; return $ uid === '' ? $ name : $ uid . self :: NAME_SEPARATOR . $ name ; }
Returns a fully - qualified name that uniquely identifies the parameter .
59,595
public static function getPersistentParams ( ) { $ rc = new \ ReflectionClass ( get_called_class ( ) ) ; $ params = [ ] ; foreach ( $ rc -> getProperties ( \ ReflectionProperty :: IS_PUBLIC ) as $ rp ) { if ( ! $ rp -> isStatic ( ) && ComponentReflection :: parseAnnotation ( $ rp , 'persistent' ) ) { $ params [ ] = $ r...
Returns array of classes persistent parameters . They have public visibility and are non - static . This default implementation detects persistent parameters by annotation
59,596
public function signalReceived ( $ signal ) { if ( ! $ this -> tryCall ( $ this -> formatSignalMethod ( $ signal ) , $ this -> params ) ) { $ class = get_class ( $ this ) ; throw new BadSignalException ( "There is no handler for signal '$signal' in class $class." ) ; } }
Calls signal handler method .
59,597
public function link ( $ destination , $ args = [ ] ) { if ( ! $ this -> _createRequestMethodReflection ) { $ this -> _createRequestMethodReflection = new \ ReflectionMethod ( Presenter :: class , 'createRequest' ) ; $ this -> _createRequestMethodReflection -> setAccessible ( true ) ; $ this -> _handleInvalidLinkMethod...
Generates URL to presenter action or signal .
59,598
public function offsetUnset ( $ name ) { $ component = $ this -> getComponent ( $ name , FALSE ) ; if ( $ component !== NULL ) { $ this -> removeComponent ( $ component ) ; } }
Removes component from the container .
59,599
protected function extractRangeRule ( Rules $ rules ) { $ controlMin = $ controlMax = null ; foreach ( $ rules as $ rule ) { $ branch = property_exists ( $ rule , 'branch' ) ? $ rule -> branch : $ rule -> subRules ; if ( ! $ branch ) { $ validator = property_exists ( $ rule , 'validator' ) ? $ rule -> validator : $ rul...
Finds minimum and maximum allowed dates .