idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
41,700 | public function seeInSession ( $ key , $ value = null ) { $ this -> debugSection ( 'Session' , json_encode ( $ this -> di [ 'session' ] -> toArray ( ) ) ) ; if ( is_array ( $ key ) ) { $ this -> seeSessionHasValues ( $ key ) ; return ; } if ( ! $ this -> di [ 'session' ] -> has ( $ key ) ) { $ this -> fail ( "No sessio... | Checks that session contains value . If value is null checks that session has key . |
41,701 | public function grabServiceFromContainer ( $ service , array $ parameters = [ ] ) { if ( ! $ this -> di -> has ( $ service ) ) { $ this -> fail ( "Service $service is not available in container" ) ; } return $ this -> di -> get ( $ service , $ parameters ) ; } | Resolves the service based on its configuration from Phalcon s DI container Recommended to use for unit testing . |
41,702 | public function addServiceToContainer ( $ name , $ definition , $ shared = false ) { try { $ service = $ this -> di -> set ( $ name , $ definition , $ shared ) ; return $ service -> resolve ( ) ; } catch ( \ Exception $ e ) { $ this -> fail ( $ e -> getMessage ( ) ) ; return null ; } } | Registers a service in the services container and resolve it . This record will be erased after the test . Recommended to use for unit testing . |
41,703 | protected function getModelRecord ( $ model ) { if ( ! class_exists ( $ model ) ) { throw new ModuleException ( __CLASS__ , "Model $model does not exist" ) ; } $ record = new $ model ; if ( ! $ record instanceof PhalconModel ) { throw new ModuleException ( __CLASS__ , "Model $model is not instance of \\Phalcon\\Mvc\\Mo... | Get Model Record |
41,704 | protected function getModelIdentity ( PhalconModel $ model ) { if ( property_exists ( $ model , 'id' ) ) { return $ model -> id ; } if ( ! $ this -> di -> has ( 'modelsMetadata' ) ) { return null ; } $ primaryKeys = $ this -> di -> get ( 'modelsMetadata' ) -> getPrimaryKeyAttributes ( $ model ) ; switch ( count ( $ pri... | Get identity . |
41,705 | protected function assertEquals ( $ expected , $ actual , $ message = '' , $ delta = 0.0 ) { \ PHPUnit \ Framework \ Assert :: assertEquals ( $ expected , $ actual , $ message , $ delta ) ; } | Checks that two variables are equal . |
41,706 | protected function assertNotEquals ( $ expected , $ actual , $ message = '' , $ delta = 0.0 ) { \ PHPUnit \ Framework \ Assert :: assertNotEquals ( $ expected , $ actual , $ message , $ delta ) ; } | Checks that two variables are not equal |
41,707 | protected function assertSame ( $ expected , $ actual , $ message = '' ) { \ PHPUnit \ Framework \ Assert :: assertSame ( $ expected , $ actual , $ message ) ; } | Checks that two variables are same |
41,708 | protected function assertNotSame ( $ expected , $ actual , $ message = '' ) { \ PHPUnit \ Framework \ Assert :: assertNotSame ( $ expected , $ actual , $ message ) ; } | Checks that two variables are not same |
41,709 | protected function assertGreaterThan ( $ expected , $ actual , $ message = '' ) { \ PHPUnit \ Framework \ Assert :: assertGreaterThan ( $ expected , $ actual , $ message ) ; } | Checks that actual is greater than expected |
41,710 | protected function assertGreaterThanOrEqual ( $ expected , $ actual , $ message = '' ) { \ PHPUnit \ Framework \ Assert :: assertGreaterThanOrEqual ( $ expected , $ actual , $ message ) ; } | Checks that actual is greater or equal than expected |
41,711 | protected function assertLessThan ( $ expected , $ actual , $ message = '' ) { \ PHPUnit \ Framework \ Assert :: assertLessThan ( $ expected , $ actual , $ message ) ; } | Checks that actual is less than expected |
41,712 | protected function assertLessThanOrEqual ( $ expected , $ actual , $ message = '' ) { \ PHPUnit \ Framework \ Assert :: assertLessThanOrEqual ( $ expected , $ actual , $ message ) ; } | Checks that actual is less or equal than expected |
41,713 | protected function assertContains ( $ needle , $ haystack , $ message = '' ) { \ PHPUnit \ Framework \ Assert :: assertContains ( $ needle , $ haystack , $ message ) ; } | Checks that haystack contains needle |
41,714 | protected function assertNotContains ( $ needle , $ haystack , $ message = '' ) { \ PHPUnit \ Framework \ Assert :: assertNotContains ( $ needle , $ haystack , $ message ) ; } | Checks that haystack doesn t contain needle . |
41,715 | protected function assertRegExp ( $ pattern , $ string , $ message = '' ) { \ PHPUnit \ Framework \ Assert :: assertRegExp ( $ pattern , $ string , $ message ) ; } | Checks that string match with pattern |
41,716 | protected function assertNotRegExp ( $ pattern , $ string , $ message = '' ) { \ PHPUnit \ Framework \ Assert :: assertNotRegExp ( $ pattern , $ string , $ message ) ; } | Checks that string not match with pattern |
41,717 | protected function assertStringStartsWith ( $ prefix , $ string , $ message = '' ) { \ PHPUnit \ Framework \ Assert :: assertStringStartsWith ( $ prefix , $ string , $ message ) ; } | Checks that a string starts with the given prefix . |
41,718 | protected function assertStringStartsNotWith ( $ prefix , $ string , $ message = '' ) { \ PHPUnit \ Framework \ Assert :: assertStringStartsNotWith ( $ prefix , $ string , $ message ) ; } | Checks that a string doesn t start with the given prefix . |
41,719 | protected function assertThatItsNot ( $ haystack , $ constraint , $ message = '' ) { $ constraint = new \ PHPUnit \ Framework \ Constraint \ LogicalNot ( $ constraint ) ; \ PHPUnit \ Framework \ Assert :: assertThat ( $ haystack , $ constraint , $ message ) ; } | Checks that haystack doesn t attend |
41,720 | public function produce ( ) { $ result = $ this -> template ; $ regex = sprintf ( '~%s([\w\.]+)%s~m' , $ this -> placeholderStart , $ this -> placeholderEnd ) ; $ matched = preg_match_all ( $ regex , $ result , $ matches , PREG_SET_ORDER ) ; if ( ! $ matched ) { return $ result ; } foreach ( $ matches as $ match ) { $ ... | Fills up template string with placed variables . |
41,721 | private function initialize ( $ request = null ) { $ this -> oldDb = null ; if ( isset ( $ this -> app [ 'db' ] ) && $ this -> app [ 'db' ] -> connection ( ) ) { $ this -> oldDb = $ this -> app [ 'db' ] ; } if ( class_exists ( Facade :: class ) ) { Facade :: clearResolvedInstances ( ) ; } $ this -> app = $ this -> kern... | Initialize the Lumen framework . |
41,722 | public static function readPrivateProperty ( $ object , $ property , $ class = null ) { if ( is_null ( $ class ) ) { $ class = $ object ; } $ property = new \ ReflectionProperty ( $ class , $ property ) ; $ property -> setAccessible ( true ) ; return $ property -> getValue ( $ object ) ; } | Read a private property of an object . |
41,723 | public static function invokePrivateMethod ( $ object , $ method , $ args = [ ] , $ class = null ) { if ( is_null ( $ class ) ) { $ class = $ object ; } $ method = new \ ReflectionMethod ( $ class , $ method ) ; $ method -> setAccessible ( true ) ; return $ method -> invokeArgs ( $ object , $ args ) ; } | Invoke a private method of an object . |
41,724 | protected function getGithubTags ( $ repo ) { $ jsonTags = $ this -> retrieveContentFromUrl ( 'https://api.github.com/repos/' . $ repo . '/tags' ) ; return array_map ( function ( $ tag ) { return $ tag [ 'name' ] ; } , json_decode ( $ jsonTags , true ) ) ; } | Returns an array of tags from a github repo . |
41,725 | private function retrieveContentFromUrl ( $ url ) { $ ctx = $ this -> prepareContext ( $ url ) ; $ body = file_get_contents ( $ url , 0 , $ ctx ) ; if ( isset ( $ http_response_header ) ) { $ code = substr ( $ http_response_header [ 0 ] , 9 , 3 ) ; if ( floor ( $ code / 100 ) > 3 ) { throw new \ Exception ( $ http_resp... | Retrieves the body - content from the provided URL . |
41,726 | private function prepareProxy ( & $ opt , $ url ) { $ scheme = parse_url ( $ url ) [ 'scheme' ] ; if ( $ scheme === 'http' && ( ! empty ( $ _SERVER [ 'HTTP_PROXY' ] ) || ! empty ( $ _SERVER [ 'http_proxy' ] ) ) ) { $ proxy = ! empty ( $ _SERVER [ 'http_proxy' ] ) ? $ _SERVER [ 'http_proxy' ] : $ _SERVER [ 'HTTP_PROXY' ... | Add proxy support to context if environment variable was set up |
41,727 | protected function retrievePharFile ( $ version , OutputInterface $ output ) { $ temp = basename ( $ this -> filename , '.phar' ) . '-temp.phar' ; try { $ sourceUrl = $ this -> getPharUrl ( $ version ) ; if ( @ copy ( $ sourceUrl , $ temp ) ) { chmod ( $ temp , 0777 & ~ umask ( ) ) ; $ phar = new \ Phar ( $ temp ) ; un... | Retrieves the latest phar file . |
41,728 | protected function getPharUrl ( $ version ) { $ sourceUrl = self :: PHAR_URL ; if ( version_compare ( PHP_VERSION , '7.0.0' , '<' ) ) { $ sourceUrl = self :: PHAR_URL_PHP54 ; } return sprintf ( $ sourceUrl , $ version ) ; } | Returns Phar file URL for specified version |
41,729 | public static function getDescription ( $ code ) { if ( isset ( self :: $ codes [ $ code ] ) ) { return sprintf ( '%d (%s)' , $ code , self :: $ codes [ $ code ] ) ; } return $ code ; } | Returns string with HTTP code and its description |
41,730 | public function persistEntity ( $ obj , $ values = [ ] ) { if ( $ values ) { $ reflectedObj = new \ ReflectionClass ( $ obj ) ; foreach ( $ values as $ key => $ val ) { $ property = $ reflectedObj -> getProperty ( $ key ) ; $ property -> setAccessible ( true ) ; $ property -> setValue ( $ obj , $ val ) ; } } $ this -> ... | Adds entity to repository and flushes . You can redefine it s properties with the second parameter . |
41,731 | public function haveFakeRepository ( $ classname , $ methods = [ ] ) { $ em = $ this -> em ; $ metadata = $ em -> getMetadataFactory ( ) -> getMetadataFor ( $ classname ) ; $ customRepositoryClassName = $ metadata -> customRepositoryClassName ; if ( ! $ customRepositoryClassName ) { $ customRepositoryClassName = '\Doct... | Mocks the repository . |
41,732 | public function seeInRepository ( $ entity , $ params = [ ] ) { $ res = $ this -> proceedSeeInRepository ( $ entity , $ params ) ; $ this -> assert ( $ res ) ; } | Flushes changes to database and executes a query with parameters defined in an array . You can use entity associations to build complex queries . |
41,733 | public function grabFromRepository ( $ entity , $ field , $ params = [ ] ) { $ this -> em -> flush ( ) ; $ data = $ this -> em -> getClassMetadata ( $ entity ) ; $ qb = $ this -> em -> getRepository ( $ entity ) -> createQueryBuilder ( 's' ) ; $ qb -> select ( 's.' . $ field ) ; $ this -> buildAssociationQuery ( $ qb ,... | Selects field value from repository . It builds query based on array of parameters . You can use entity associations to build complex queries . |
41,734 | public function grabEntitiesFromRepository ( $ entity , $ params = [ ] ) { $ this -> em -> flush ( ) ; $ data = $ this -> em -> getClassMetadata ( $ entity ) ; $ qb = $ this -> em -> getRepository ( $ entity ) -> createQueryBuilder ( 's' ) ; $ qb -> select ( 's' ) ; $ this -> buildAssociationQuery ( $ qb , $ entity , '... | Selects entities from repository . It builds query based on array of parameters . You can use entity associations to build complex queries . |
41,735 | public function grabEntityFromRepository ( $ entity , $ params = [ ] ) { $ this -> em -> flush ( ) ; $ data = $ this -> em -> getClassMetadata ( $ entity ) ; $ qb = $ this -> em -> getRepository ( $ entity ) -> createQueryBuilder ( 's' ) ; $ qb -> select ( 's' ) ; $ this -> buildAssociationQuery ( $ qb , $ entity , 's'... | Selects a single entity from repository . It builds query based on array of parameters . You can use entity associations to build complex queries . |
41,736 | protected function buildAssociationQuery ( $ qb , $ assoc , $ alias , $ params ) { $ data = $ this -> em -> getClassMetadata ( $ assoc ) ; foreach ( $ params as $ key => $ val ) { if ( isset ( $ data -> associationMappings ) ) { if ( $ map = array_key_exists ( $ key , $ data -> associationMappings ) ) { if ( is_array (... | It s Fuckin Recursive! |
41,737 | public function matches ( array $ jsonType ) { if ( array_key_exists ( 0 , $ this -> jsonArray ) && is_array ( $ this -> jsonArray [ 0 ] ) ) { $ msg = '' ; foreach ( $ this -> jsonArray as $ array ) { $ res = $ this -> typeComparison ( $ array , $ jsonType ) ; if ( $ res !== true ) { $ msg .= "\n" . $ res ; } } if ( $ ... | Checks data against passed JsonType . If matching fails function returns a string with a message describing failure . On success returns true . |
41,738 | public function actionVerifyEmail ( $ token ) { try { $ model = new VerifyEmailForm ( $ token ) ; } catch ( InvalidArgumentException $ e ) { throw new BadRequestHttpException ( $ e -> getMessage ( ) ) ; } if ( $ user = $ model -> verifyEmail ( ) ) { if ( Yii :: $ app -> user -> login ( $ user ) ) { Yii :: $ app -> sess... | Verify email address |
41,739 | public function actionResendVerificationEmail ( ) { $ model = new ResendVerificationEmailForm ( ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> validate ( ) ) { if ( $ model -> sendEmail ( ) ) { Yii :: $ app -> session -> setFlash ( 'success' , 'Check your email for further instructions.'... | Resend verification email |
41,740 | protected function getTargetUrl ( $ request ) { $ queries = Arr :: except ( $ request -> query ( ) , [ 'code' , 'state' ] ) ; return $ request -> url ( ) . ( empty ( $ queries ) ? '' : '?' . http_build_query ( $ queries ) ) ; } | Build the target business url . |
41,741 | public static function buildDependencies ( DependencyBuilder $ dependencies ) { $ classes = [ DoctrineBundle :: class , Column :: class , ] ; foreach ( $ classes as $ class ) { $ dependencies -> addClassDependency ( $ class , 'orm' ) ; } } | Central method to add dependencies needed for Doctrine ORM . |
41,742 | public function getPathForFutureClass ( string $ className ) { $ classLoader = $ this -> getClassLoader ( ) ; foreach ( $ classLoader -> getPrefixesPsr4 ( ) as $ prefix => $ paths ) { if ( 0 === strpos ( $ className , $ prefix ) ) { return $ paths [ 0 ] . '/' . str_replace ( '\\' , '/' , substr ( $ className , \ strlen... | Returns the relative path to where a new class should live . |
41,743 | public function isNamespaceConfiguredToAutoload ( string $ namespace ) : bool { $ namespace = trim ( $ namespace , '\\' ) . '\\' ; $ classLoader = $ this -> getClassLoader ( ) ; foreach ( $ classLoader -> getPrefixesPsr4 ( ) as $ prefix => $ paths ) { if ( 0 === strpos ( $ namespace , $ prefix ) ) { return true ; } } f... | Returns if the namespace is configured by composer autoloader . |
41,744 | public function updateForUserClass ( string $ yamlSource , UserClassConfiguration $ userConfig , string $ userClass ) : string { $ this -> manipulator = new YamlSourceManipulator ( $ yamlSource ) ; $ this -> normalizeSecurityYamlFile ( ) ; $ this -> updateProviders ( $ userConfig , $ userClass ) ; if ( $ userConfig -> ... | Updates security . yaml contents based on a new User class . |
41,745 | public static function hasSuffix ( string $ value , string $ suffix ) : bool { return 0 === strcasecmp ( $ suffix , substr ( $ value , - \ strlen ( $ suffix ) ) ) ; } | Looks for suffixes in strings in a case - insensitive way . |
41,746 | private function addNodeAfterProperties ( Node $ newNode ) { $ classNode = $ this -> getClassNode ( ) ; $ targetNode = $ this -> findLastNode ( function ( $ node ) { return $ node instanceof Node \ Stmt \ Property ; } , [ $ classNode ] ) ; if ( ! $ targetNode ) { $ targetNode = $ this -> findLastNode ( function ( $ nod... | Adds this new node where a new property should go . |
41,747 | public function addClassDependency ( string $ class , string $ package , bool $ required = true , bool $ devDependency = false ) { if ( $ devDependency ) { $ this -> devDependencies [ ] = [ 'class' => $ class , 'name' => $ package , 'required' => $ required , ] ; } else { $ this -> dependencies [ ] = [ 'class' => $ cla... | Add a dependency that will be reported if the given class is missing . |
41,748 | public function doesDocBlockContainAnnotation ( string $ annotation ) : bool { $ docComment = ( new \ ReflectionClass ( $ this -> fullClassName ) ) -> getDocComment ( ) ; if ( false === $ docComment ) { return false ; } return false !== strpos ( $ docComment , $ annotation ) ; } | An imperfect but simple way to check for the presence of an annotation . |
41,749 | public function relativizePath ( $ absolutePath ) : string { $ absolutePath = $ this -> normalizeSlashes ( $ absolutePath ) ; if ( false === strpos ( $ absolutePath , $ this -> rootDirectory ) ) { return $ absolutePath ; } $ absolutePath = $ this -> realPath ( $ absolutePath ) ; $ relativePath = ltrim ( implode ( '' , ... | Attempts to make the path relative to the root directory . |
41,750 | public function generateClass ( string $ className , string $ templateName , array $ variables = [ ] ) : string { $ targetPath = $ this -> fileManager -> getRelativePathForFutureClass ( $ className ) ; if ( null === $ targetPath ) { throw new \ LogicException ( sprintf ( 'Could not determine where to locate the new cla... | Generate a new file for a class from a template . |
41,751 | public function generateFile ( string $ targetPath , string $ templateName , array $ variables ) { $ variables = array_merge ( $ variables , [ 'helper' => $ this -> twigHelper , ] ) ; $ this -> addOperation ( $ targetPath , $ templateName , $ variables ) ; } | Generate a normal file from a template . |
41,752 | public function createClassNameDetails ( string $ name , string $ namespacePrefix , string $ suffix = '' , string $ validationErrorMessage = '' ) : ClassNameDetails { $ fullNamespacePrefix = $ this -> namespacePrefix . '\\' . $ namespacePrefix ; if ( '\\' === $ name [ 0 ] ) { $ className = substr ( $ name , 1 ) ; } els... | Creates a helper object to get data about a class name . |
41,753 | public function writeChanges ( ) { foreach ( $ this -> pendingOperations as $ targetPath => $ templateData ) { if ( isset ( $ templateData [ 'contents' ] ) ) { $ this -> fileManager -> dumpFile ( $ targetPath , $ templateData [ 'contents' ] ) ; continue ; } $ this -> fileManager -> dumpFile ( $ targetPath , $ this -> g... | Actually writes and file changes that are pending . |
41,754 | public function getAllActiveEvents ( ) : array { $ activeEvents = [ ] ; foreach ( self :: $ eventsMap as $ eventName => $ eventClass ) { if ( ! class_exists ( $ eventClass ) ) { continue ; } $ activeEvents [ ] = $ eventName ; } $ listeners = $ this -> eventDispatcher -> getListeners ( ) ; $ activeEvents = array_unique ... | Returns all known event names in the system . |
41,755 | public function getEventClassName ( string $ event ) { if ( isset ( self :: $ eventsMap [ $ event ] ) ) { return self :: $ eventsMap [ $ event ] ; } $ listeners = $ this -> eventDispatcher -> getListeners ( $ event ) ; if ( empty ( $ listeners ) ) { return null ; } foreach ( $ listeners as $ listener ) { if ( ! \ is_ar... | Attempts to get the event class for a given event . |
41,756 | private function changeValueInYaml ( $ value ) { $ originalVal = $ this -> getCurrentData ( ) ; $ endValuePosition = $ this -> findEndPositionOfValue ( $ originalVal ) ; $ newYamlValue = $ this -> convertToYaml ( $ value ) ; if ( ! \ is_array ( $ originalVal ) && \ is_array ( $ value ) ) { $ this -> manuallyIncrementIn... | Replaces the value at the current position with this value . |
41,757 | private function getCurrentData ( int $ limitLevels = 0 ) { $ data = $ this -> currentData ; $ path = \ array_slice ( $ this -> currentPath , 0 , \ count ( $ this -> currentPath ) - $ limitLevels ) ; foreach ( $ path as $ key ) { if ( ! \ array_key_exists ( $ key , $ data ) ) { throw new \ LogicException ( sprintf ( 'C... | Returns the value in the current data that is currently being looked at . |
41,758 | private function guessNextArrayTypeAndAdvance ( ) : string { while ( true ) { if ( $ this -> isEOF ( ) ) { throw new \ LogicException ( 'Could not determine array type' ) ; } $ nextCharacter = substr ( $ this -> contents , $ this -> currentPosition , 1 ) ; ++ $ this -> currentPosition ; if ( $ this -> isCharLineBreak (... | Attempts to guess if the array at the current position is a multi - line array or an inline array . |
41,759 | private function indentMultilineYamlArray ( string $ yaml ) : string { $ yaml = str_replace ( "\n" , "\n" . $ this -> getCurrentIndentation ( ) , $ yaml ) ; return $ this -> getCurrentIndentation ( ) . $ yaml ; } | Takes an unindented multi - line YAML string and indents it so it can be inserted into the current position . |
41,760 | protected function pStmt_ClassMethod ( Stmt \ ClassMethod $ node ) { $ classMethod = parent :: pStmt_ClassMethod ( $ node ) ; if ( $ node -> returnType ) { $ classMethod = str_replace ( ') :' , '):' , $ classMethod ) ; } return $ classMethod ; } | Overridden to change coding standards . |
41,761 | private function displayRequirements ( ) { $ requirements = $ this -> getChecker ( ) -> requirements ( ) ; $ this -> frame ( 'Application requirements' ) ; $ this -> table ( [ 'Status' , 'Message' ] , [ [ $ requirements [ 'status' ] , $ requirements [ 'message' ] ] ] ) ; } | Display LogViewer requirements . |
41,762 | private function displayMessages ( ) { $ messages = $ this -> getChecker ( ) -> messages ( ) ; $ rows = [ ] ; foreach ( $ messages [ 'files' ] as $ file => $ message ) { $ rows [ ] = [ $ file , $ message ] ; } $ this -> frame ( 'LogViewer messages' ) ; $ this -> table ( [ 'File' , 'Message' ] , $ rows ) ; } | Display LogViewer messages . |
41,763 | public function get ( $ key , $ locale = null ) { return $ this -> translator -> get ( "log-viewer::levels.$key" , [ ] , $ locale ? : $ this -> getLocale ( ) ) ; } | Get the translated level . |
41,764 | public function index ( ) { $ stats = $ this -> logViewer -> statsTable ( ) ; $ chartData = $ this -> prepareChartData ( $ stats ) ; $ percents = $ this -> calcPercentages ( $ stats -> footer ( ) , $ stats -> header ( ) ) ; return $ this -> view ( 'dashboard' , compact ( 'chartData' , 'percents' ) ) ; } | Show the dashboard . |
41,765 | public function listLogs ( Request $ request ) { $ stats = $ this -> logViewer -> statsTable ( ) ; $ headers = $ stats -> header ( ) ; $ rows = $ this -> paginate ( $ stats -> rows ( ) , $ request ) ; return $ this -> view ( 'logs' , compact ( 'headers' , 'rows' ) ) ; } | List all logs . |
41,766 | public function show ( $ date , Request $ request ) { $ level = 'all' ; $ log = $ this -> getLogOrFail ( $ date ) ; $ query = $ request -> get ( 'query' ) ; $ levels = $ this -> logViewer -> levelsNames ( ) ; $ entries = $ log -> entries ( $ level ) -> paginate ( $ this -> perPage ) ; return $ this -> view ( 'show' , c... | Show the log . |
41,767 | public function showByLevel ( $ date , $ level , Request $ request ) { if ( $ level === 'all' ) return redirect ( ) -> route ( $ this -> showRoute , [ $ date ] ) ; $ log = $ this -> getLogOrFail ( $ date ) ; $ query = $ request -> get ( 'query' ) ; $ levels = $ this -> logViewer -> levelsNames ( ) ; $ entries = $ this ... | Filter the log entries by level . |
41,768 | public function delete ( Request $ request ) { abort_unless ( $ request -> ajax ( ) , 405 , 'Method Not Allowed' ) ; $ date = $ request -> get ( 'date' ) ; return response ( ) -> json ( [ 'result' => $ this -> logViewer -> delete ( $ date ) ? 'success' : 'error' ] ) ; } | Delete a log . |
41,769 | protected function prepareChartData ( StatsTable $ stats ) { $ totals = $ stats -> totals ( ) -> all ( ) ; return json_encode ( [ 'labels' => Arr :: pluck ( $ totals , 'label' ) , 'datasets' => [ [ 'data' => Arr :: pluck ( $ totals , 'value' ) , 'backgroundColor' => Arr :: pluck ( $ totals , 'color' ) , 'hoverBackgroun... | Prepare chart data . |
41,770 | protected function calcPercentages ( array $ total , array $ names ) { $ percents = [ ] ; $ all = Arr :: get ( $ total , 'all' ) ; foreach ( $ total as $ level => $ count ) { $ percents [ $ level ] = [ 'name' => $ names [ $ level ] , 'count' => $ count , 'percent' => $ all ? round ( ( $ count / $ all ) * 100 , 2 ) : 0 ... | Calculate the percentage . |
41,771 | public static function make ( array $ data , LogLevelsContract $ levels , $ locale = null ) { return new self ( $ data , $ levels , $ locale ) ; } | Make a stats table instance . |
41,772 | protected function prepareHeader ( array $ data ) { return array_merge_recursive ( [ 'date' => $ this -> translate ( 'general.date' ) , 'all' => $ this -> translate ( 'general.all' ) , ] , $ this -> levels -> names ( $ this -> locale ) ) ; } | Prepare table header . |
41,773 | protected function prepareFooter ( array $ data ) { $ footer = [ ] ; foreach ( $ data as $ date => $ levels ) { foreach ( $ levels as $ level => $ count ) { if ( ! isset ( $ footer [ $ level ] ) ) { $ footer [ $ level ] = 0 ; } $ footer [ $ level ] += $ count ; } } return $ footer ; } | Prepare table footer . |
41,774 | public function totals ( ) { $ totals = Collection :: make ( ) ; foreach ( Arr :: except ( $ this -> footer ( ) , 'all' ) as $ level => $ count ) { $ totals -> put ( $ level , [ 'label' => $ this -> translate ( "levels.$level" ) , 'value' => $ count , 'color' => $ this -> color ( $ level ) , 'highlight' => $ this -> co... | Get totals . |
41,775 | public function stats ( ) { $ stats = [ ] ; foreach ( $ this -> items as $ date => $ log ) { $ stats [ $ date ] = $ log -> stats ( ) ; } return $ stats ; } | Get logs statistics . |
41,776 | public function total ( $ level = 'all' ) { return ( int ) $ this -> sum ( function ( Log $ log ) use ( $ level ) { return $ log -> entries ( $ level ) -> count ( ) ; } ) ; } | Get entries total . |
41,777 | public function menu ( $ trans = true ) { $ menu = [ ] ; foreach ( $ this -> items as $ date => $ log ) { $ menu [ $ date ] = $ log -> menu ( $ trans ) ; } return $ menu ; } | Get logs menu . |
41,778 | public function load ( $ raw ) { foreach ( LogParser :: parse ( $ raw ) as $ entry ) { list ( $ level , $ header , $ stack ) = array_values ( $ entry ) ; $ this -> push ( new LogEntry ( $ level , $ header , $ stack ) ) ; } return $ this ; } | Load raw log entries . |
41,779 | public function paginate ( $ perPage = 20 ) { $ page = request ( ) -> get ( 'page' , 1 ) ; $ path = request ( ) -> url ( ) ; return new LengthAwarePaginator ( $ this -> forPage ( $ page , $ perPage ) , $ this -> count ( ) , $ perPage , $ page , compact ( 'path' ) ) ; } | Paginate log entries . |
41,780 | public function filterByLevel ( $ level ) { return $ this -> filter ( function ( LogEntry $ entry ) use ( $ level ) { return $ entry -> isSameLevel ( $ level ) ; } ) ; } | Get filtered log entries by level . |
41,781 | public function stats ( ) { $ counters = $ this -> initStats ( ) ; foreach ( $ this -> groupBy ( 'level' ) as $ level => $ entries ) { $ counters [ $ level ] = $ count = count ( $ entries ) ; $ counters [ 'all' ] += $ count ; } return $ counters ; } | Get log entries stats . |
41,782 | public function tree ( $ trans = false ) { $ tree = $ this -> stats ( ) ; array_walk ( $ tree , function ( & $ count , $ level ) use ( $ trans ) { $ count = [ 'name' => $ trans ? log_levels ( ) -> get ( $ level ) : $ level , 'count' => $ count , ] ; } ) ; return $ tree ; } | Get the log entries navigation tree . |
41,783 | private function initStats ( ) { $ levels = array_merge_recursive ( [ 'all' ] , array_keys ( log_viewer ( ) -> levels ( true ) ) ) ; return array_map ( function ( ) { return 0 ; } , array_flip ( $ levels ) ) ; } | Init stats counters . |
41,784 | private function prepareFooter ( StatsTable $ stats ) { $ files = [ 'count' => count ( $ stats -> rows ( ) ) . ' log file(s)' ] ; return $ files + $ stats -> footer ( ) ; } | Prepare footer . |
41,785 | public function statsTable ( $ locale = null ) { return StatsTable :: make ( $ this -> stats ( ) , $ this -> levels , $ locale ) ; } | Get logs statistics table . |
41,786 | private function registerLogViewer ( ) { $ this -> singleton ( Contracts \ LogViewer :: class , LogViewer :: class ) ; if ( $ facade = $ this -> config ( ) -> get ( 'log-viewer.facade' ) ) { $ this -> alias ( $ facade , Facades \ LogViewer :: class ) ; } } | Register the log data class . |
41,787 | protected function setLocale ( $ locale ) { if ( is_null ( $ locale ) || $ locale === 'auto' ) { $ locale = app ( ) -> getLocale ( ) ; } $ this -> locale = $ locale ; return $ this ; } | Set table locale . |
41,788 | private function init ( ) { $ this -> header = $ this -> prepareHeader ( $ this -> data ) ; $ this -> rows = $ this -> prepareRows ( $ this -> data ) ; $ this -> footer = $ this -> prepareFooter ( $ this -> data ) ; } | Prepare the table . |
41,789 | private static function parseRawData ( $ raw ) { $ pattern = '/\[' . REGEX_DATE_PATTERN . ' ' . REGEX_TIME_PATTERN . '\].*/' ; preg_match_all ( $ pattern , $ raw , $ headings ) ; $ data = preg_split ( $ pattern , $ raw ) ; if ( $ data [ 0 ] < 1 ) { $ trash = array_shift ( $ data ) ; unset ( $ trash ) ; } return [ $ hea... | Parse raw data . |
41,790 | public function download ( $ date , $ filename = null , $ headers = [ ] ) { if ( is_null ( $ filename ) ) { $ filename = "laravel-{$date}.log" ; } $ path = $ this -> filesystem -> path ( $ date ) ; return response ( ) -> download ( $ path , $ filename , $ headers ) ; } | Download a log file . |
41,791 | private function refresh ( ) { $ this -> setHandler ( $ this -> config -> get ( 'logging.default' , 'stack' ) ) ; $ this -> messages = [ 'handler' => '' , 'files' => [ ] , ] ; $ this -> files = [ ] ; $ this -> checkHandler ( ) ; $ this -> checkLogFiles ( ) ; return $ this ; } | Refresh the checks . |
41,792 | private function checkLogFile ( $ path ) { $ status = true ; $ filename = basename ( $ path ) ; $ message = "The log file [$filename] is valid." ; if ( $ this -> isSingleLogFile ( $ filename ) ) { $ this -> status = $ status = false ; $ this -> messages [ 'files' ] [ $ filename ] = $ message = "You have a single log fi... | Check a log file . |
41,793 | private function isInvalidLogDate ( $ file ) { $ pattern = $ this -> filesystem -> getPattern ( ) ; return ( ( bool ) preg_match ( "/{$pattern}/" , $ file , $ matches ) ) === false ; } | Check the date of the log file . |
41,794 | private function mapLogsRoutes ( ) { $ this -> prefix ( 'logs' ) -> name ( 'logs.' ) -> group ( function ( ) { $ this -> get ( '/' , 'LogViewerController@listLogs' ) -> name ( 'list' ) ; $ this -> delete ( 'delete' , 'LogViewerController@delete' ) -> name ( 'delete' ) ; $ this -> prefix ( '{date}' ) -> group ( function... | Map the logs routes . |
41,795 | private function registerLogLevels ( ) { $ this -> singleton ( Contracts \ Utilities \ LogLevels :: class , function ( $ app ) { $ config = $ app [ 'config' ] ; $ translator = $ app [ 'translator' ] ; return new Utilities \ LogLevels ( $ translator , $ config -> get ( 'log-viewer.locale' ) ) ; } ) ; } | Register the log levels . |
41,796 | private function registerFilesystem ( ) { $ this -> singleton ( Contracts \ Utilities \ Filesystem :: class , function ( $ app ) { $ config = $ app [ 'config' ] ; $ files = $ app [ 'files' ] ; $ filesystem = new Utilities \ Filesystem ( $ files , $ config -> get ( 'log-viewer.storage-path' ) ) ; $ pattern = $ config ->... | Register the log filesystem . |
41,797 | public function serializeToXml ( ) { $ xml = new \ SimpleXMLElement ( '<?xml version="1.0" encoding="utf-8"?><WebsiteConfiguration></WebsiteConfiguration>' ) ; $ index_document_part = $ xml -> addChild ( 'IndexDocument' ) ; $ error_document_part = $ xml -> addChild ( 'ErrorDocument' ) ; $ index_document_part -> addChil... | Serialize the WebsiteConfig object into xml string . |
41,798 | protected function parseDataFromResponse ( ) { $ content = $ this -> rawResponse -> body ; $ xml = simplexml_load_string ( $ content ) ; if ( isset ( $ xml -> UploadId ) ) { return strval ( $ xml -> UploadId ) ; } throw new OssException ( "cannot get UploadId" ) ; } | Get uploadId in result and return |
41,799 | protected function parseDataFromResponse ( ) { $ content = $ this -> rawResponse -> body ; $ config = new LifecycleConfig ( ) ; $ config -> parseFromXml ( $ content ) ; return $ config ; } | Parse the LifecycleConfig object from the response |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.