Further modules included.
[yaffs-website] / web / modules / contrib / drupalmoduleupgrader / src / Utility / Path / Drupal7 / PathUtility.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Drupal\drupalmoduleupgrader\Utility\Path\Drupal7\PathUtility.
6  */
7
8 namespace Drupal\drupalmoduleupgrader\Utility\Path\Drupal7;
9
10 use Drupal\drupalmoduleupgrader\Utility\Path\PathUtilityBase;
11
12 /**
13  * Represents a Drupal 7 route path.
14  */
15 class PathUtility extends PathUtilityBase {
16
17   /**
18    * {@inheritdoc}
19    */
20   public static function getComponent($value) {
21     return new PathComponent($value);
22   }
23
24   /**
25    * Returns if the path has %wildcards or placeholders (%) in it.
26    *
27    * @return boolean
28    */
29   public function isDynamic() {
30     return ($this->hasWildcards() || $this->hasPlaceholders());
31   }
32
33   /**
34    * Returns if there are placeholders in the path.
35    *
36    * @return boolean
37    */
38   public function hasPlaceholders() {
39     return ($this->getPlaceholders()->count() > 0);
40   }
41
42   /**
43    * Returns every placeholder in the path, keyed by position.
44    *
45    * @return static
46    */
47   public function getPlaceholders() {
48     return $this->filter(function(PathComponent $component) {
49       return $component->isPlaceholder();
50     });
51   }
52
53   /**
54    * Returns a copy of the collection with all placeholders removed.
55    *
56    * @return static
57    */
58   public function deletePlaceholders() {
59     return $this->filter(function(PathComponent $component) {
60       return (! $component->isPlaceholder());
61     });
62   }
63
64 }