Created
January 15, 2020 15:38
-
-
Save Gydo194/347a391748bdf88987d2b4d5f288fae8 to your computer and use it in GitHub Desktop.
PHP Class diagram generator shell script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ $# -ne 1 ]]; then | |
echo "No file specified" | |
exit | |
fi | |
FILE=$1 | |
#public properties | |
egrep 'public \$[a-zA-Z_]' $FILE | tr -d '$;=[]' | awk '{print "+ " $2}' | |
echo | |
#private properties | |
egrep 'private \$[a-zA-Z_]' $FILE | tr -d '$;=[]' | awk '{print "- " $2}' | |
echo "-------------------------------------------------------------" | |
#getters | |
egrep 'public function get[A-Za-z]' $FILE | tr -d ':' | awk '{print "+ " $3}' | |
echo | |
#setters | |
egrep 'public function set[A-Za-z]' $FILE | tr -d '$:=[]?' | awk '{$1=""; $2=""; $NF=""; gsub(/^[ \t]+/, "", $0); print "+ " $0}' | sed 's/[[:space:]])/)/g' | |
echo | |
#public functions | |
egrep 'public function [^set|get][A-Za-z]' $FILE | tr -d '$:=[]?' | awk '{$1=""; $2=""; $NF=""; gsub(/^[ \t]+/, "", $0); print "+ " $0}' | sed 's/[[:space:]])/)/g' | |
echo | |
#private functions | |
egrep 'private function [^set|get][A-Za-z]' $FILE | tr -d '$:=[]?' | awk '{$1=""; $2=""; $NF=""; gsub(/^[ \t]+/, "", $0); print "+ " $0}' | sed 's/[[:space:]])/)/g' | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment