Skip to content

Commit

Permalink
documented functions
Browse files Browse the repository at this point in the history
  • Loading branch information
davidperezgar committed Dec 14, 2024
1 parent 2908a19 commit f6016ae
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ private function check_for_privacy_notes( Check_Result $result, string $readme_f
$files_ext = $this->filter_files_for_external( $files, $result->plugin()->path() );

foreach( $files_ext as $file ) {
$lines = file( $file );

}


Expand Down
48 changes: 40 additions & 8 deletions includes/Traits/External_Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ protected function load_domains_mentioned_in_readme( $readme_file, $existing_tld
$domain = end( $parts ) . '.' . $domain_tld;

//Find domain
$key = $this->getKeyDomainMentionedInReadme( $domain );
$key = $this->get_key_domain_mentioned_in_readme( $domain );
if ( false !== $key ) {
// If found, just add URL
$domains_mentioned[ $key ]['urls'][] = $url;
Expand All @@ -132,7 +132,7 @@ protected function load_domains_mentioned_in_readme( $readme_file, $existing_tld
} else {
//Not found, create it.
$domain_mentioned = array(
'domains' => $this->addDomainsOfSameService( $domain ),
'domains' => $this->add_domains_of_same_service( $domain ),
'urls' => array( $url ),
'paths' => array(),
);
Expand All @@ -159,7 +159,15 @@ protected function load_domains_mentioned_in_readme( $readme_file, $existing_tld
return $domains_mentioned;
}

function getKeyDomainMentionedInReadme( $string ) {
/**
* Get key domain mentioned in readme file.
*
* @since 1.4.0
*
* @param string $string String.
* @return string|bool Key of domain mentioned in readme file, or false if not found.
*/
function get_key_domain_mentioned_in_readme( $string ) {
if ( ! empty( $this->domainsMentionedReadme ) ) {
foreach ( $this->domainsMentionedReadme as $key => $domains ) {
if ( ! empty( $domains['domains'] ) ) {
Expand All @@ -175,7 +183,15 @@ function getKeyDomainMentionedInReadme( $string ) {
return false;
}

function addDomainsOfSameService( $domain ) {
/**
* Add domains of the same service.
*
* @since 1.4.0
*
* @param string $domain Domain.
* @return array An array containing domains of the same service.
*/
protected function add_domains_of_same_service( $domain ) {
$domains = array( $domain );
$domainsOfTheSameService = array(
'paypal.com' => [ 'paypal.com', 'paypalobjects.com' ],
Expand All @@ -198,17 +214,33 @@ function addDomainsOfSameService( $domain ) {
return $domains;
}

function isDomainMentionedInReadme( $domain ) {
$key = $this->getKeyDomainMentionedInReadme( $domain );
/**
* Check if domain is mentioned in readme file.
*
* @since 1.4.0
*
* @param string $domain Domain.
* @return bool True if domain is mentioned in readme file, false otherwise.
*/
protected function is_domain_mentioned_in_readme( $domain ) {
$key = $this->get_key_domain_mentioned_in_readme( $domain );
if ( false !== $key ) {
return true;

Check warning on line 228 in includes/Traits/External_Utils.php

View check run for this annotation

Codecov / codecov/patch

includes/Traits/External_Utils.php#L225-L228

Added lines #L225 - L228 were not covered by tests
}

return false;

Check warning on line 231 in includes/Traits/External_Utils.php

View check run for this annotation

Codecov / codecov/patch

includes/Traits/External_Utils.php#L231

Added line #L231 was not covered by tests
}

function isDomainDocumentedReadme( $domain ) {
$key = $this->getKeyDomainMentionedInReadme( $domain );
/**
* Check if domain is documented in readme file.
*
* @since 1.4.0
*
* @param string $domain Domain.
* @return bool True if domain is documented in readme file, false otherwise.
*/
protected function is_domain_documented_readme( $domain ) {
$key = $this->get_key_domain_mentioned_in_readme( $domain );
$privacy = false;
$terms = false;

Check warning on line 245 in includes/Traits/External_Utils.php

View check run for this annotation

Codecov / codecov/patch

includes/Traits/External_Utils.php#L242-L245

Added lines #L242 - L245 were not covered by tests

Expand Down

0 comments on commit f6016ae

Please sign in to comment.